I have a Google Web Toolkit (GWT) - Application which I run in three different modes:
- Deployed on Tomcat
- Hosted Mode
- Junit Test
How can I configure log4j.properties so that each of those modes logs correctly?
If I use ${catalina.base}
I cannot use it in hosted mode and in Junit tests and if I just use a relative logs/myapplication.log
, it won't work with Tomcat because then I get:
java.io.FileNotFoundException: log/myapplication.log (Keine Berechtigung)
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.
At the moment my log4j.properties contains the following entries for file logging:
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