Tomcat 5.5 : How to redirect the logging output to one file per web application
6,015
I found the following information, guess this should help you.
Try this,
- Each application must use its own log4j. You can achieve this by placing
log4j.jar
inWEB-INF/lib
of each application. - In each log4j's configuration file (default location is
WEB-INF/classes
), specify the log file name, e.g.log4j.appender.AppLog.File=${catalina.home}/logs/app1.log
. - Add
swallowOutput="true"
for each context so stdout, stderr will go to your own log.
We do this on Tomcat 5.5 but I think it should work on 6.0 also.
EDIT: Here is our META-INF/context.xml
:
<?xml version="1.0" encoding="UTF-8"?>
<Context override="true" swallowOutput="true" useNaming="false">
<WatchedResource>WEB-INF/web.xml</WatchedResource>
<Manager pathname=""/>
</Context>
Further reading:
- http://tomcat.apache.org/tomcat-5.5-doc/logging.html
- http://tomcat.apache.org/tomcat-6.0-doc/logging.html
Related videos on Youtube
Author by
MRalwasser
Updated on September 17, 2022Comments
-
MRalwasser over 1 year
How to configure tomcat 5.5 (or 6.0) that the output of stdout and stderr of each web application / context will go to one logfile?
I only managed to get the stderr to a specific logfile - the stdout of the applications still went to catalina.out.
-
Brian Deterling over 13 yearsDo you have swallowOutput set to true on your contexts? "If the value of this flag is true, the bytes output to System.out and System.err by the web application will be redirected to the web application logger. If not specified, the default value of the flag is false."
-