log4j.properties
log4j.rootLogger=info, stdout, R
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%-5p %d [%t] %c (%F:%L) ===> %m%n
#2014-08-25 21:46:48,505 [main] INFO com.za.IndexOfDemo (IndexOfDemo.java:12) ===> string is: abdd,def,ghi
log4j.appender.R=org.apache.log4j.RollingFileAppender
log4j.appender.R.File=${catalina.home}/logs/server.log
log4j.appender.R.MaxFileSize=10MB
log4j.appender.R.MaxBackupIndex=10
log4j.appender.R.layout=org.apache.log4j.PatternLayout
log4j.appender.R.layout.ConversionPattern=%d{ISO8601} %-5.5p [%t] %-20.20c{2} - %m%n
log4j.properties和tomcat-juli-adapters.jar放在 ..\apache-tomcat-6.0.41\lib\目录下
tomcat-juli.jar 放在 ..\apache-tomcat-6.0.41\bin\目录下
附:
tomcat-juli-adapters.jar和tomcat-juli.jar包 下载地址: http://www.apache.org/dist/tomcat/tomcat-6/v6.0.41/bin/extras/
log4j 1.2.16下载地址: http://www.apache.org/dist/logging/log4j/1.2.17/log4j-1.2.17.zip