title: Log4j2 : How to configure multiple Appender with same type in Yaml configuration
body: <p>I'm trying to have 2 RollingRandomAccessFile in the same YAML configuration. I'm able to do it in XML but not in YAML. As a result, I want two files "application.log" and "payload.log".</p>
  
  <p>Here's my working XML configuration : </p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;Configuration status="debug"&gt;
      &lt;Appenders&gt;
  
          &lt;Console name="CONSOLE" target="SYSTEM_OUT"&gt;
              &lt;PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/&gt;
          &lt;/Console&gt;
  
          &lt;RollingRandomAccessFile name="PAYLOAD" fileName="logs/payload.log"
                                   filePattern="logs/$${date:yyyy-MM}/payload-%d{MM-dd-yyyy}-%i.log.gz"&gt;
              &lt;PatternLayout&gt;
                  &lt;pattern&gt;[%-5level] %d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %c{1} - %msg%n&lt;/pattern&gt;
              &lt;/PatternLayout&gt;
              &lt;Policies&gt;
                  &lt;SizeBasedTriggeringPolicy size="1 KB"/&gt;
              &lt;/Policies&gt;
          &lt;/RollingRandomAccessFile&gt;
  
          &lt;RollingRandomAccessFile name="APPLICATION" fileName="logs/application.log"
                                   filePattern="logs/$${date:yyyy-MM}/application-%d{MM-dd-yyyy}-%i.log.gz"&gt;
              &lt;PatternLayout&gt;
                  &lt;pattern&gt;[%-5level] %d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %c{1} - %msg%n&lt;/pattern&gt;
              &lt;/PatternLayout&gt;
              &lt;Policies&gt;
                  &lt;SizeBasedTriggeringPolicy size="1 KB"/&gt;
              &lt;/Policies&gt;
          &lt;/RollingRandomAccessFile&gt;
  
      &lt;/Appenders&gt;
  
      &lt;Loggers&gt;
          &lt;Root level="info" additivity="false"&gt;
              &lt;appender-ref ref="CONSOLE" level="trace"/&gt;
              &lt;appender-ref ref="APPLICATION" level="trace"/&gt;
              &lt;appender-ref ref="PAYLOAD" level="trace"/&gt;
          &lt;/Root&gt;
      &lt;/Loggers&gt;
  
  &lt;/Configuration&gt;
  </code></pre>
  
  <p>Here's my non-working YAML configuration. The second declaration of RollingRandomAccessFile overrides the first one, resulting with only "application.log" :</p>
  
  <pre><code>Configuration:
    status: debug
  
    Appenders:
      Console:
        name: CONSOLE
        target: SYSTEM_OUT
        PatternLayout:
          Pattern: "%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"
      RollingRandomAccessFile:
        name: PAYLOAD
        fileName: logs/payload.log
        filePattern: "logs/$${date:yyyy-MM}/payload-%d{MM-dd-yyyy}-%i.log.gz"
        PatternLayout:
          Pattern: "%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"
        Policies:
          SizeBasedTriggeringPolicy:
            size: 1 KB
      RollingRandomAccessFile:
        name: APPLICATION
        fileName: logs/application.log
        filePattern: "logs/$${date:yyyy-MM}/application-%d{MM-dd-yyyy}-%i.log.gz"
        PatternLayout:
          Pattern: "%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"
        Policies:
          SizeBasedTriggeringPolicy:
            size: 1 KB
  
    Loggers:
      Root:
        level: debug
        AppenderRef:
          - ref: CONSOLE
          - ref: PAYLOAD
          - ref: APPLICATION
  </code></pre>
  
  <p>Here's what I tried using List at the Appender level and with that there's no ouput, even the console :</p>
  
  <pre><code>Configuration:
    status: debug
  
    Appenders:
      - Console:
        name: CONSOLE
        target: SYSTEM_OUT
        PatternLayout:
          Pattern: "%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"
      - RollingRandomAccessFile:
        name: PAYLOAD
        fileName: logs/payload.log
        filePattern: "logs/$${date:yyyy-MM}/payload-%d{MM-dd-yyyy}-%i.log.gz"
        PatternLayout:
          Pattern: "%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"
        Policies:
          SizeBasedTriggeringPolicy:
            size: 1 KB
      - RollingRandomAccessFile:
        name: APPLICATION
        fileName: logs/application.log
        filePattern: "logs/$${date:yyyy-MM}/application-%d{MM-dd-yyyy}-%i.log.gz"
        PatternLayout:
          Pattern: "%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"
        Policies:
          SizeBasedTriggeringPolicy:
            size: 1 KB
  
    Loggers:
      Root:
        level: debug
        AppenderRef:
          - ref: CONSOLE
          - ref: PAYLOAD
          - ref: APPLICATION
  </code></pre>
  
  <p>If I replace the second RollingRandomAccessFile by a RollingFile, it works perfectly.</p>