title: Tomcat log4j logging relative to application path?
body: <p>I have a Google Web Toolkit (GWT) - Application which I run in three different modes:</p>
  
  <ol>
  <li>Deployed on Tomcat</li>
  <li>Hosted Mode</li>
  <li>Junit Test</li>
  </ol>
  
  <p><strong>How can I configure log4j.properties so that each of those modes logs correctly?</strong></p>
  
  <p>If I use <code>${catalina.base}</code> I cannot use it in hosted mode and in Junit tests and if I just use a relative <code>logs/myapplication.log</code>, it won't work with Tomcat because then I get:</p>
  
  <pre><code>java.io.FileNotFoundException: log/myapplication.log (Keine Berechtigung)
  </code></pre>
  
  <p>I wouldn't mind having the logs in webapps/myapplication/logs if the log directory could be specified relatively to the application path but it would also be ok if the log files were just in /var/log/tomcat7/... or some other log folder.</p>
  
  <p>At the moment my log4j.properties contains the following entries for file logging:</p>
  
  <pre><code>log4j.appender.file=org.apache.log4j.FileAppender
  log4j.appender.file.File=${catalina.base}/logs/myapplication.log
  log4j.appender.file.layout=org.apache.log4j.PatternLayout
  log4j.appender.file.layout.ConversionPattern=%c %C %d{ABSOLUTE} %-5p %C{1}: %m%n
  log4j.appender.file.threshold=DEBUG
  log4j.appender.file.Append=false
  </code></pre>