title: Integrate Spring with Log4j2
body: <p>I would like to Spring use Log4j2 for logging because sometimes i would like to get debug level. I've read tons of related topics and examples but noithing is working.. I managed to configure log4j2 and log from my own classes but not from spring.
  What i got:<br/>
  Maven dependencies:</p>
  
  <pre><code>    &lt;dependencies&gt;
      &lt;!-- SERVLT API --&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;javax.servlet&lt;/groupId&gt;
          &lt;artifactId&gt;javax.servlet-api&lt;/artifactId&gt;
          &lt;version&gt;3.0.1&lt;/version&gt;
          &lt;scope&gt;provided&lt;/scope&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;junit&lt;/groupId&gt;
          &lt;artifactId&gt;junit&lt;/artifactId&gt;
          &lt;version&gt;3.8.1&lt;/version&gt;
          &lt;scope&gt;test&lt;/scope&gt;
      &lt;/dependency&gt;
  
      &lt;!-- APACHE TILES --&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.apache.tiles&lt;/groupId&gt;
          &lt;artifactId&gt;tiles-extras&lt;/artifactId&gt;
          &lt;version&gt;3.0.5&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;!-- APACHE FILEUPLOAD --&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;commons-fileupload&lt;/groupId&gt;
          &lt;artifactId&gt;commons-fileupload&lt;/artifactId&gt;
          &lt;version&gt;1.3.1&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;!-- Spring and Transactions --&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework&lt;/groupId&gt;
          &lt;artifactId&gt;spring-context&lt;/artifactId&gt;
          &lt;version&gt;${spring-framework.version}&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework&lt;/groupId&gt;
          &lt;artifactId&gt;spring-tx&lt;/artifactId&gt;
          &lt;version&gt;${spring-framework.version}&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework&lt;/groupId&gt;
          &lt;artifactId&gt;spring-web&lt;/artifactId&gt;
          &lt;version&gt;${spring-framework.version}&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework&lt;/groupId&gt;
          &lt;artifactId&gt;spring-webmvc&lt;/artifactId&gt;
          &lt;version&gt;${spring-framework.version}&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;!-- Spring ORM support --&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework&lt;/groupId&gt;
          &lt;artifactId&gt;spring-orm&lt;/artifactId&gt;
          &lt;version&gt;${spring-framework.version}&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;!-- SPRING SECURITY --&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.security&lt;/groupId&gt;
          &lt;artifactId&gt;spring-security-web&lt;/artifactId&gt;
          &lt;version&gt;${spring-framework.version}&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.security&lt;/groupId&gt;
          &lt;artifactId&gt;spring-security-config&lt;/artifactId&gt;
          &lt;version&gt;${spring-framework.version}&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;!-- LOGGING --&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;org.apache.logging.log4j&lt;/groupId&gt;
          &lt;artifactId&gt;log4j-core&lt;/artifactId&gt;
          &lt;version&gt;${logger.version}&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.apache.logging.log4j&lt;/groupId&gt;
          &lt;artifactId&gt;log4j-api&lt;/artifactId&gt;
          &lt;version&gt;${logger.version}&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.apache.logging.log4j&lt;/groupId&gt;
          &lt;artifactId&gt;log4j-1.2-api&lt;/artifactId&gt;
          &lt;version&gt;${logger.version}&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.apache.logging.log4j&lt;/groupId&gt;
          &lt;artifactId&gt;log4j-slf4j-impl&lt;/artifactId&gt;
          &lt;version&gt;${logger.version}&lt;/version&gt;
      &lt;/dependency&gt;
  
  
      &lt;!-- Hibernate --&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.hibernate&lt;/groupId&gt;
          &lt;artifactId&gt;hibernate-entitymanager&lt;/artifactId&gt;
          &lt;version&gt;${hibernate.version}&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.hibernate&lt;/groupId&gt;
          &lt;artifactId&gt;hibernate-core&lt;/artifactId&gt;
          &lt;version&gt;${hibernate.version}&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;!-- POSTGRE DRIVER --&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.postgresql&lt;/groupId&gt;
          &lt;artifactId&gt;postgresql&lt;/artifactId&gt;
          &lt;version&gt;9.4.1207.jre7&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;commons-dbcp&lt;/groupId&gt;
          &lt;artifactId&gt;commons-dbcp&lt;/artifactId&gt;
          &lt;version&gt;1.4&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;!-- JACKSON --&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;com.fasterxml.jackson.core&lt;/groupId&gt;
          &lt;artifactId&gt;jackson-databind&lt;/artifactId&gt;
          &lt;version&gt;2.7.0&lt;/version&gt;
      &lt;/dependency&gt;
  
  &lt;/dependencies&gt;
  </code></pre>
  
  <p>log4j.xml: (edit: file name is log4j2.xml -sorry for mistake)</p>
  
  <pre><code>&lt;Configuration status="debug"&gt;
  &lt;Appenders&gt;
      &lt;RollingFile name="systemLog" fileName="C:\\test\logs\system.log" includeLocation="true"
                  filePattern="C:\\test\logs\system-%d{MM-dd-yyyy}-%i.log.gz"&gt;
          &lt;PatternLayout pattern="%d{ISO8601} - %-5level [%t] %C %M %m%n" /&gt;
          &lt;Policies&gt;
              &lt;TimeBasedTriggeringPolicy /&gt;
              &lt;SizeBasedTriggeringPolicy size="15 MB"/&gt;
          &lt;/Policies&gt;
      &lt;/RollingFile&gt;
      &lt;Async name="systemAsyncAppender" includeLocation="true"&gt;
          &lt;AppenderRef ref="systemLog" /&gt;
      &lt;/Async&gt;
  &lt;/Appenders&gt;
  &lt;Loggers&gt;
      &lt;Logger name="org.springframework.web" level="debug"&gt;
          &lt;AppenderRef ref="systemAsyncAppender" /&gt;
      &lt;/Logger&gt;
      &lt;Root level="debug" includeLocation="true"&gt;
          &lt;AppenderRef ref="systemAsyncAppender" /&gt;
      &lt;/Root&gt;
  &lt;/Loggers&gt;
  </code></pre>
  
  <p></p>
  
  <p>If there is something relevalt that i didnt told - tell me<br/></p>
  
  <p>I will be realy greatfull for helping me out with this</p>