title: How to have Spring boot use a log4j.xml configuration file?
body: <p>I have a simple Spring Boot application that builds to a jar file.  I have a log4j.xml file in src/main/resources/log4j.xml that looks like this (basic sample file from the log4j docs):</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8" ?&gt;
  &lt;!DOCTYPE log4j:configuration SYSTEM "log4j.dtd"&gt;
  &lt;log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/"&gt;
      &lt;appender name="stdout" class="org.apache.log4j.ConsoleAppender"&gt;
          &lt;layout class="org.apache.log4j.PatternLayout"&gt;
              &lt;!-- Pattern to output the caller's file name and line number --&gt;
              &lt;param name="ConversionPattern" value="%5p [%t] (%F:%L) - %m%n"/&gt;
          &lt;/layout&gt;
      &lt;/appender&gt;
      &lt;appender name="R" class="org.apache.log4j.RollingFileAppender"&gt;
          &lt;param name="file" value="/tmp/logs/sample.log"/&gt;
          &lt;param name="MaxFileSize" value="100KB"/&gt;
          &lt;!-- Keep one backup file --&gt;
          &lt;param name="MaxBackupIndex" value="1"/&gt;
          &lt;layout class="org.apache.log4j.PatternLayout"&gt;
              &lt;param name="ConversionPattern" value="%p %t %c - %m%n"/&gt;
          &lt;/layout&gt;
      &lt;/appender&gt;
      &lt;root&gt;
          &lt;priority value="debug"/&gt;
          &lt;appender-ref ref="stdout"/&gt;
          &lt;appender-ref ref="R"/&gt;
      &lt;/root&gt;
  &lt;/log4j:configuration&gt;
  </code></pre>
  
  <p>Logging only goes to the console though (/tmp/logs/sample.log never gets created), as it the log4j.xml file is being ignored.</p>
  
  <p>The file shows up in the root of the jar, which I assume is correct.  What else do I need to do to have this logging configuration picked up?</p>
  
  <p>If it makes any difference, the project is using Gradle, not Maven.</p>