How to make Log4j2 configurable by environment using Spring Boot 1.3.6.RELEASE
<p>I would like to change some properties from the <code>log4j2.xml</code> file depending on the my application.properties,  for example define some properties and then substitute in the <code>log4j2</code> those properties that are parameters.</p>
<p>I ran different approaches but I still did not get the right thing.  I would like to have different configs depending on the environment (DEV, QA or PROD).  How to accomplish this?</p>
<p>I'm trying to have this in my properties</p>
<pre><code>#Place holders for log4j2.xml file
log.file.path=/opt/tomcat/logs
log.file.name=dummydummy
log.file.size=100 MB
log.level=DEBUG
</code></pre>
<p>My log4j2 below.</p>
<pre class="lang-xml prettyprint-override"><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;Configuration status=&quot;WARN&quot; monitorInterval=&quot;30&quot;&gt;
    &lt;Properties&gt;
        &lt;Property name=&quot;PID&quot;&gt;????&lt;/Property&gt;
        &lt;property name=&quot;name&quot;&gt;my-log&lt;/property&gt;
    &lt;/Properties&gt;
    &lt;Appenders&gt;
        &lt;RollingFile name=&quot;file&quot; fileName=&quot;${log.file.path}${log.file}.log&quot;
            filePattern=&quot;${log.file.path}${log.file}-%d{yyyy-MM-dd}-%i.log.gz&quot;&gt;
            &lt;PatternLayout
                pattern=&quot;%d{yyyy-MM-dd HH:mm:ss.SSS} %5p ${sys:PID} --- [%t] %c{1}(%M:%L) : %m%n%wEx&quot; /&gt;
            &lt;Policies&gt;
                &lt;TimeBasedTriggeringPolicy /&gt;&lt;!-- Rotated everyday --&gt;
                &lt;SizeBasedTriggeringPolicy size=&quot;${log.file.size}&quot; /&gt; &lt;!-- Or every 100 MB --&gt;
            &lt;/Policies&gt;
        &lt;/RollingFile&gt;
        &lt;Console name=&quot;Console&quot; target=&quot;SYSTEM_OUT&quot; follow=&quot;true&quot;&gt;
            &lt;PatternLayout
                pattern=&quot;%clr{%d{yyyy-MM-dd HH:mm:ss.SSS}}{faint} %clr{%5p} %clr{${sys:PID}}{magenta} %clr{---}{faint} %clr{[%t]}{faint} %clr{%c{1}(%M:%L)}{cyan} %clr{:}{faint} %m%n%wEx&quot; /&gt;
        &lt;/Console&gt;
    &lt;/Appenders&gt;
    &lt;Loggers&gt;
        &lt;Logger name=&quot;org.hibernate.validator.internal.util.Version&quot;
            level=&quot;warn&quot; /&gt;
        &lt;Logger name=&quot;org.apache.coyote.http11.Http11NioProtocol&quot; level=&quot;warn&quot; /&gt;
        &lt;Logger name=&quot;org.apache.tomcat.util.net.NioSelectorPool&quot; level=&quot;warn&quot; /&gt;
        &lt;Logger name=&quot;org.apache.catalina.startup.DigesterFactory&quot; level=&quot;error&quot; /&gt;
        &lt;Logger name=&quot;org.springframework.web&quot; level=&quot;error&quot; /&gt;

        &lt;Root level=&quot;${log.level}&quot;&gt;
            &lt;AppenderRef ref=&quot;Console&quot; /&gt;
            &lt;AppenderRef ref=&quot;file&quot; /&gt;
        &lt;/Root&gt;
    &lt;/Loggers&gt;
&lt;/Configuration&gt;
</code></pre>