Thursday, January 27, 2011

Logging in Tomcat

Follow the following steps to setup a file named tomcat.log that has internal Tomcat logging output to it:

Create a file called log4j.properties with the following content and save it into common/classes.
            log4j.rootLogger=DEBUG, R
            log4j.appender.R=org.apache.log4j.RollingFileAppender
            log4j.appender.R.File=${catalina.home}/logs/tomcat.log
            log4j.appender.R.MaxFileSize=10MB
            log4j.appender.R.MaxBackupIndex=10
            log4j.appender.R.layout=org.apache.log4j.PatternLayout
            log4j.appender.R.layout.ConversionPattern=%p %t %c - %m%n
         


Download Log4J (v1.2 or later) and place the log4j jar in $CATALINA_HOME/common/lib.
Download Commons Logging and place the commons-logging-x.y.z.jar (not commons-logging-api-x.y.z.jar) in $CATALINA_HOME/common/lib with the log4j jar.
Start Tomcat
 commons-logging-x.y.z.jarhttp://mirror.its.uidaho.edu/pub/apache/commons/logging/ 

No comments:

Post a Comment