title: log4j2 specify relative path to tomcat home dir for FileAppender
body: <p>I am trying to configure log4j2 for my tomcat server running locally.  I am unable to pipe the logs to a location that is relative to the tomcat install.</p>
  
  <p>If I specify an absolute path it works.  If I use a relative path it outputs to the location of <code>System.getProperty("user.dir")</code>.</p>
  
  <p>But when I try to use either <code>${catalina.home}</code> or <code>${catalina.base}</code> it does not work. If I output those two system properties on startup, they are defined and point to the proper location.</p>
  
  <p>Also, </p>
  
  <ul>
  <li>Tomcat 7.0.26</li>
  <li>servlet 2.5</li>
  <li>log4j2.0 beta 8</li>
  <li>we are using slf4j with log4j2 behind it.  </li>
  <li>I setup all loggers to be async through the environment variable <code>-DLog4jContextSelector=org.apache.logging.log4j.core.async.AsyncLoggerContextSelector</code>.</li>
  </ul>
  
  <p>My feeling is that Tomcat might not be fully initialized when it processes the log4j2.xml?  Any ideas would be greatly appreciated!</p>
  
  <p>Here is my <code>log4j2.xml</code>:</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;configuration status="debug" name="LoggingConfig"&gt; 
    &lt;appenders&gt;
      &lt;FastFile name="ALog" fileName="${catalina.home}/logs/test.log" immediateFlush="true" append="true"&gt;
        &lt;PatternLayout&gt;
          &lt;pattern&gt;%d %p %c{1.} [%t] %m%n&lt;/pattern&gt;
        &lt;/PatternLayout&gt;
      &lt;/FastFile&gt;
    &lt;/appenders&gt;
  
    &lt;loggers&gt;
      &lt;logger name="a.namespace.dir" level="info" additivity="false"&gt;
        &lt;appender-ref ref="ALog"/&gt;
      &lt;/logger&gt;
  
      &lt;root level="info"&gt;
        &lt;appender-ref ref="ALog"/&gt;
      &lt;/root&gt;
    &lt;/loggers&gt;
  
  &lt;/configuration&gt;
  </code></pre>
  
  <p>From catalina.out</p>
  
  <pre><code>2013-07-31 11:22:00,313 DEBUG Calling createAppender on class org.apache.logging.log4j.core.appender.FastFileAppender for element FastFile with params(fileName="${catalina.home}/logs/test.log", append="true", name="ALog", immediateFlush="true", suppressExceptions="null", PatternLayout(%d %p %c{1.} [%t] %m%n), null, advertise="null", advertiseURI="null", Configuration(LoggingConfig))
  
  2013-07-31 11:22:00,315 DEBUG Starting FastFileManager ${catalina.home}/logs/test.log
  
  2013-07-31 11:22:00,316 DEBUG Calling createAppenders on class org.apache.logging.log4j.core.config.plugins.AppendersPlugin for element appenders with params(appenders={ALog})
  
  2013-07-31 11:22:00,317 DEBUG Generated plugins in 0.000016000 seconds
  
  2013-07-31 11:22:00,318 DEBUG Calling createAppenderRef on class org.apache.logging.log4j.core.config.AppenderRef for element appender-ref with params(ref="ALog", level="null", null)
  
  2013-07-31 11:22:00,320 DEBUG Calling createLogger on class org.apache.logging.log4j.core.config.LoggerConfig for element logger with params(additivity="false", level="info", name="a.namespace.dir", includeLocation="null", appender-ref={org.apache.logging.log4j.core.config.AppenderRef@6e8ef177}, properties={}, Configuration(LoggingConfig), null)
  
  2013-07-31 11:22:00,321 DEBUG Calling createAppenderRef on class org.apache.logging.log4j.core.config.AppenderRef for element appender-ref with params(ref="ALog", level="null", null)
  
  2013-07-31 11:22:00,322 DEBUG Calling createLogger on class org.apache.logging.log4j.core.config.LoggerConfig$RootLogger for element root with params(additivity="null", level="info", includeLocation="null", appender-ref={org.apache.logging.log4j.core.config.AppenderRef@6a8ef455}, properties={}, Configuration(LoggingConfig), null)
  
  2013-07-31 11:22:00,323 DEBUG Calling createLoggers on class org.apache.logging.log4j.core.config.plugins.LoggersPlugin for element loggers with params(loggers={a.namespace.dir, root})
  </code></pre>