1、tomcat的安装路径下tomcat home下的common文件夹下的classes文件夹中创建log4j.properties文件,即 apache-tomcat-5.5.20\common\classes
log4j.rootLogger=info,Console,R
log4j.appender.Console=org.apache.log4j.ConsoleAppenderlog4j.appender.Console.layout=org.apache.log4j.PatternLayout#log4j.appender.Console.layout.ConversionPattern=%d [%t] %-5p %c - %m%nlog4j.appender.Console.layout.ConversionPattern=%d{yy-MM-dd HH:mm:ss} %5p %c{1}:%L - %m%nlog4j.appender.R=org.apache.log4j.DailyRollingFileAppenderlog4j.appender.R.File=${catalina.home}/logs/tomcat.loglog4j.appender.R.layout=org.apache.log4j.PatternLayoutlog4j.appender.R.layout.ConversionPattern=%d{yyyy.MM.dd HH:mm:ss} %5p %c{1}(%L):? %m%nlog4j.logger.org.apache=info,Rlog4j.logger.org.apache.catalina.core.ContainerBase.[Catalina].[localhost]=DEBUG, Rlog4j.logger.org.apache.catalina.core=info,Rlog4j.logger.org.apache.catalina.session=info,R2、将log4j-1.2.15.jar和commons-logging.jar包拷贝到Tomcat 5.5.20/common/lib下即可