1.Tomcat/lib下面添加log4j.properties 如下:
log4j.rootLogger=ERROR,R
log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
log4j.appender.CONSOLE.layout.ConversionPattern=[%p]%t-%c-%m%n
log4j.appender.R=org.apache.log4j.RollingFileAppender
log4j.appender.R.File=${catalina.home}/logs/tomcat.log
log4j.appender.R.MaxFileSize=1024MB
log4j.appender.R.MaxBackupIndex=10
log4j.appender.R.layout=org.apache.log4j.PatternLayout
log4j.appender.R.layout.ConversionPattern=[%p]%t-%c-%m%n
log4j.logger.org.apache.catalina=INFO,R,CONSOLE
2.下载log4j最新版本1.2或者更新版本
指定地址下载tomcat-juli.jar,tomcat-juli-adapters.jar
4.替换bin下面的tomcat-juli.jar,并且把tomcat-juli-adapters.jar添加到lib目录下
5.启动tomcat即可