标签:io ar sp 文件 on log ad tt app
要点,下载相应的jar包tomcat-juli-adapters.jar、tomcat-juli.jar、log4j-1.2.15.jar,配置Log4j
1.tomcat目录的lib下,添加log4j.properties、tomcat-juli-adapters.jar、log4j-1.2.15.jar
2.tomcat目录的bin下,添加tomcat-juli.jar(替换)
3.tomcat目录的conf下,编辑context.xml,Context增加属性swallowOutput="true"
4.tomcat目录的conf下,删除文件logging.properties
5.完成
附简单配置,即同时输出到控制台、文件
log4j.appender.console_out=org.apache.log4j.ConsoleAppender
log4j.appender.console_out.layout=org.apache.log4j.PatternLayout
log4j.appender.console_out.layout.ConversionPattern=[TomcatLog4j_Console] [%-5p] [%d{yyyy-MM-dd HH:mm:ss,SSS}] %c - %m%n
log4j.appender.root_out=org.apache.log4j.DailyRollingFileAppender
log4j.appender.root_out.File=${catalina.home}/logs/log4j
log4j.appender.root_out.DatePattern=‘-‘yyyy-MM-dd‘.log‘
log4j.appender.root_out.layout=org.apache.log4j.PatternLayout
log4j.appender.root_out.layout.ConversionPattern=[TomcatLog4j_Root] [%-5p] [%d{yyyy-MM-dd HH:mm:ss,SSS}] %c - %m%n
log4j.rootLogger=INFO,root_out,console_out
标签:io ar sp 文件 on log ad tt app
原文地址:http://my.oschina.net/u/1587335/blog/336282