Raible's Wiki

Raible Designs
Wiki Home
News
Recent Changes

AppFuse

Homepage
  - Korean
  - Chinese
  - Italian
  - Japanese

QuickStart Guide
  - Chinese
  - French
  - German
  - Italian
  - Korean
  - Portuguese
  - Spanish
  - Japanese

User Guide
  - Korean
  - Chinese

Tutorials
  - Chinese
  - German
  - Italian
  - Korean
  - Portuguese
  - Spanish

FAQ
  - Korean

Latest Downloads

Other Applications

Struts Resume
Security Example
Struts Menu

Set your name in
UserPreferences

Edit this page


Referenced by
AppFuseSupport




JSPWiki v2.2.33

[RSS]


Hide Menu

Tomcat5Logging


Configuring (and more importantly, supressing) Tomcat 5.x logging using Log4j

PLEASE NOTE: These instructions are for setting up Tomcat with log4j logging, your web application can still have its own log4j.properties deployed to its WEB-INF/classes directory..

Create a log4j.properties file in $CATALINA_HOME/common/classes

log4j.rootLogger=ERROR, R
log4j.appender.R=org.apache.log4j.DailyRollingFileAppender
log4j.appender.R.File=${catalina.home}/logs/tomcat.log
log4j.appender.R.DatePattern='.'yyyy-MM-dd
log4j.appender.R.layout=org.apache.log4j.PatternLayout
log4j.appender.R.layout.ConversionPattern={%p} %c{2} %x %m%n

You also need to copy commons-logging.jar and log4j-1.2.9.jar to $CATALINA_HOME/common/lib. Note, some references say copy these files to $CATALINA_HOME/server/lib, but for me, copying to common/lib worked fine.

Then, in your application log4j.properties file ($APPFUSE_HOME/web/WEB-INF/classes), add this:

# Suppress the tomcat logging whilst DEBUG is switched on
log4j.logger.org.apache.catalina.core=ERROR
log4j.logger.org.apache.catalina.session=ERROR
log4j.logger.org.apache.jasper.compiler=ERROR

Because if, whilst developing, you set your root logger to DEBUG, then it seems to set the Tomcat logging to DEBUG as well, and you will probably witness thousands of lines of compilation trace from the Jasper compiler!

It is of course, better practice, to keep your application log4j.properties ROOT log level set to WARN or ERROR, and just turn on debugging for your own application classes! (ie. org.appfuse=DEBUG )

Note: If you want Tomcat logging to stdout as well, then your $CATALINA_HOME/common/classes/log4j.properties file should look like this:

log4j.rootLogger=ERROR, stdout, TOMCAT

log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{dd-MM-yy HH:mm:ss:SSS} - {%p} %c{2} Thread [%t]; %x %m%n

log4j.appender.TOMCAT=org.apache.log4j.DailyRollingFileAppender
log4j.appender.TOMCAT.File=${catalina.home}/logs/tomcat.log
log4j.appender.TOMCAT.DatePattern='.'yyyy-MM-dd
log4j.appender.TOMCAT.layout=org.apache.log4j.PatternLayout
log4j.appender.TOMCAT.layout.ConversionPattern=%d{dd-MM-yy HH:mm:ss:SSS} - {%p} %c{2} Thread [%t]; %x %m%n

For more on Tomcat 5 see here Tomcat 5 Upgrade

For the official Tomcat 5.5 docs on logging see here Tomcat 5.5 Logging

If you cannot get the above instructions to work, then should remove the files you placed within the tomcat distribution and Tomcat will revert back to using commons logging.



Go to top   Edit this page   More info...   Attach file...
This page last changed on 06-Nov-2006 13:52:59 MST by BenGill.