title: Log4J2 configuration in 3.0 servlet
body: <p>I tried to set up LOG4J according documentation (and related SO questions), but it does not create supposed file, but there is such log in WildFly:</p>
  
  <pre><code>No Log4j context configuration provided. This is very unusual
  </code></pre>
  
  <p>web.xml</p>
  
  <pre><code>&lt;web-app xmlns="http://java.sun.com/xml/ns/javaee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
         version="3.0"&gt;
  
  &lt;context-param&gt;
        &lt;param-name&gt;log4jConfigLocation&lt;/param-name&gt;
       &lt;param-value&gt;/WEB-INF/classes/log4j2.xml&lt;/param-value&gt;
  &lt;/context-param&gt;
  </code></pre>
  
  <p>app.war/WEB-INF/classes/log4j2.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;Configuration monitorInterval="30"&gt;
      &lt;!-- http://logging.apache.org/log4j/2.x/manual/configuration.html --&gt;
      &lt;Properties&gt;
          &lt;Property name="filename"&gt;c:/oauth.log&lt;/Property&gt;
      &lt;/Properties&gt;
  
      &lt;Filter type="ThresholdFilter" level="trace"/&gt;
  
      &lt;Appenders&gt;
          &lt;Appender type="File" name="File" fileName="${filename}"&gt;
              &lt;Layout type="PatternLayout"&gt;
                  &lt;Pattern&gt;%d %p %C{1.} [%t] %m%n&lt;/Pattern&gt;
              &lt;/Layout&gt;
          &lt;/Appender&gt;
          &lt;File name="MyFile" fileName="c:/oauth2.log" immediateFlush="true"&gt;
              &lt;PatternLayout pattern="%d{yyy-MM-dd HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/&gt;
          &lt;/File&gt;
      &lt;/Appenders&gt;
  
      &lt;Loggers&gt;
          &lt;Logger name="cz.literak.demo" level="debug" additivity="true"&gt;
              &lt;AppenderRef ref="File"/&gt;
          &lt;/Logger&gt;
          &lt;Root level="error"&gt;
              &lt;AppenderRef ref="MyFile"/&gt;
          &lt;/Root&gt;
      &lt;/Loggers&gt;
  
  &lt;/Configuration&gt;
  </code></pre>
  
  <p>app.war/WEB-INF/lib</p>
  
  <pre><code>commons-logging-1.1.3.jar
  json-smart-1.1.1.jar
  log4j-api-2.0-rc1.jar
  log4j-core-2.0-rc1.jar
  log4j-jcl-2.0-rc1.jar
  </code></pre>
  
  <p>Could you tell me what is wrong? I tried to comment out context param in web.xml and rely on autoconfiguration but there is no change.</p>
  
  <p>EDIT</p>
  
  <p>when I added following code</p>
  
  <pre><code>&lt;context-param&gt;
      &lt;param-name&gt;log4jContextName&lt;/param-name&gt;
      &lt;param-value&gt;oauthDemo&lt;/param-value&gt;
  &lt;/context-param&gt;
  </code></pre>
  
  <p>it failed differently (I do not have time to investigate now)</p>
  
  <pre><code>07:41:29,269 INFO  [io.undertow.servlet] (MSC service thread 1-12) Log4jServletContainerInitializer starting up Log4j in Servlet 3.0+ environment.
  07:41:29,644 INFO  [stdout] (MSC service thread 1-12) 2014-02-20 07:41:29,643 ERROR FileManager (c:/oauth2.log) java.io.FileNotFoundException: c:\oauth2.log (PĹ™Ă­stup byl odepĹ™en)
  07:41:29,646 INFO  [stdout] (MSC service thread 1-12) 2014-02-20 07:41:29,645 ERROR Unable to invoke method createAppender in class org.apache.logging.log4j.core.appender.FileAppender for element File 07:41:29,647 INFO    [stdout] (MSC service thread 1-12)    at org.apache.logging.log4j.core.config.BaseConfiguration.createPluginObject(BaseConfiguration.java:913)
  </code></pre>