用log4j代替tomcat自身的log

根据上一篇说的,如果想用log4j来详细的打印出 tomcat的log,用下面的方法可以做到
首先,将common-logging和log4j的包放入tomat/common/lib下
然后将log4j.properties文件放入tomcat/common/classes下
就可以了..

下面是log4j.properties的配置

#
# Configures Log4j as the Tomcat system logger
# to output info level messages into a rolling log file.

#
log4j.rootLogger=INFO, R

#
# To continue using the "catalina.out" file (which grows forever),
# comment out the above line and uncomment the next.

#
#log4j.rootLogger=DEBUG, A1

#
# Configuration for standard output ("catalina.out").
#

log4j.appender.A1=org.apache.log4j.ConsoleAppender
log4j.appender.A1.layout=org.apache.log4j.PatternLayout


#
# Print the date in ISO 8601 format
#
log4j.appender.A1.layout.ConversionPattern=%d [%t] %-5p %c - %m%n

#
# Configuration for a rolling log file ("tomcat.log").
#
log4j.appender.R=org.apache.log4j.DailyRollingFileAppender
log4j.appender.R.DatePattern='.'yyyy-MM-dd

#
# Edit the next line to point to your logs directory.
# The last part of the name is the log file name.
#
#log4j.appender.R.File=F:/tomcat/logs/tomcat.log
#log4j.appender.R.layout=org.apache.log4j.PatternLayout
log4j.appender.R=org.apache.log4j.ConsoleAppender
log4j.appender.R.layout=org.apache.log4j.PatternLayout
log4j.appender.R.layout.ConversionPattern=%d %p [%c] - <%m>%n

#
# Print the date in ISO 8601 format
#
log4j.appender.R.layout.ConversionPattern=%d [%t] %-5p %c - %m%n

#
# Application logging options
#

#log4j.logger.org.apache=DEBUG
#log4j.logger.org.apache=INFO
#log4j.logger.org.apache.struts=DEBUG
#log4j.logger.org.apache.struts=INFO

如果想打印去文件,修改一下上面的文件(其实也就是去掉两行注释),我这个是打印到控制台的
这个文件如果看不懂的话,先面壁半小时
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值