title: Log4j - Invalid element or attribute in RollingRandomAccessFile
body: <p>I'm kind of new to Log4J (and Java in general). I'm trying to output some logs to logstash. I ran into some issues with the logstash's built-in log4j input type. For that reason, I wanted to use the <a href="https://github.com/logstash/log4j-jsonevent-layout" rel="noreferrer">json_event layout</a> approach. While I believe I have everything setup properly, I'm getting an error when I start my app that says:</p>
  
  <pre><code>ERROR: RollingRandomAccessFile contains an invalid element or attribute "layout".
  </code></pre>
  
  <p>I do not understand why I'm getting this, or how to resolve this. I'm more interested in getting my logs in the json_event format than anything else. Currently, my log4j2.xml file looks like this:</p>
  
  <pre><code>&lt;Configuration status="WARN" monitorInterval="30"&gt;
    &lt;Appenders&gt;
      &lt;RollingRandomAccessFile name="RollingFile" fileName="/logs/recent.log"
        filePattern="/logs/$${date:yyyy-MM}/server-%d{yyyy-MM-dd-HH}-%i.log.gz"&gt;
        &lt;layout class="net.logstash.log4j.JSONEventLayoutV1" /&gt;
        &lt;Policies&gt;
          &lt;TimeBasedTriggeringPolicy interval="4" modulate="true"/&gt;
          &lt;SizeBasedTriggeringPolicy size="100 MB"/&gt;
        &lt;/Policies&gt;
      &lt;/RollingRandomAccessFile&gt;
      &lt;Async name="AsyncFile"&gt;
        &lt;AppenderRef ref="RollingFile"/&gt;
      &lt;/Async&gt;
    &lt;/Appenders&gt;
    &lt;Loggers&gt;
      &lt;Logger name="com.myApp" level="trace" additivity="false"&gt;
        &lt;AppenderRef ref="AsyncFile"/&gt;
      &lt;/Logger&gt;
      &lt;Root level="trace"&gt;
        &lt;AppenderRef ref="AsyncFile"/&gt;
      &lt;/Root&gt;
    &lt;/Loggers&gt;
  &lt;/Configuration&gt;
  </code></pre>
  
  <p>To start my app, I'm running the following at the command-line:</p>
  
  <pre><code>java -Dlog4j.configurationFile=log4j2.xml -cp "/home/ubuntu/jsonevent-layout-1.6.jar" -Xms256m -Xmx1024m -jar myApp.jar
  </code></pre>
  
  <p>I've confirmed that the path to jsonevent-layout-1.6.jar is correct. My app successfully logs if I remove the new layout. So, I know that log4j is running properly. I know my app runs just fine. This problem is isolated to using the json_event layout. Can someone please help me get this issue resolved? I'm totally stumped as to what I'm doing wrong.</p>
  
  <p>Thank you</p>