title: How can I change the default location of log4j2.xml in Java Spring Boot?
body: <p>Log4j2 is working nicely with Spring Boot through the <code>log4j2.xml</code> configuration file in the root classpath, exactly as the documentation states.</p>
  
  <p>When trying to move this file to a different location though, I'm not able to pass the new location to Spring at startup. From <a href="http://docs.spring.io/spring-boot/docs/current-SNAPSHOT/reference/htmlsingle/#boot-features-custom-log-configuration" rel="noreferrer">the documentation</a>:</p>
  
  <blockquote>
    <p>The various logging systems can be activated by including the
    appropriate libraries on the classpath, and further customized by
    providing a suitable configuration file in the root of the classpath,
    or <strong>in a location specified by the Spring Environment property
    <code>logging.config</code></strong>.</p>
  </blockquote>
  
  <p>I tried setting the new location with a Java system property</p>
  
  <pre><code>java -jar -Dlogging.config="classpath:/config/log4j2.xml" target/app.jar
  </code></pre>
  
  <p>or using an external <code>application.properties</code> containing the relevant property</p>
  
  <pre><code>logging.config=classpath:/config/log4j2.xml
  </code></pre>
  
  <p>But I am regularly greeted by the following error message.</p>
  
  <pre><code>ERROR StatusLogger No log4j2 configuration file found. Using default configuration: logging only errors to the console.
  </code></pre>