问题描述
我的log4j.properties文件-
My log4j.properties file -
log4j.rootLogger=INFO, stdout
# =============== console output appender =====================
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=[%d{HH:mm:ss}] %5p: [%c{1}] %m%n
# =================== common logging =========================
# The log level for all classes that are not configured below.
log4j.logger.petascope=INFO
log4j.logger.petascope.wcps=DEBUG
log4j.logger.petascope.wcst=DEBUG
log4j.logger.petascope.wcs=DEBUG
log4j.logger.petascope.wcs2=TRACE
我想在stdout上甚至显示DEBUG和TRACE消息,所以我更改了以下行
I want to display even DEBUG and TRACE messages on stdout, so I changed the following line
log4j.rootLogger=TRACE, stdout
但是当我在Tomcat控制台上查看日志回显时,我看不到任何变化,我仍然只看到INFO,WARN ...消息.
But I don't see any changes when I view the logs echoes on Tomcat Console, I still see only INFO, WARN ... messages.
推荐答案
好吧,即使您将root logger设为TRACE,您的log4j.logger.petascope
(指向INFO)也将覆盖petascope.*包的默认root logger的TRACE. ,这就是您看不到任何调试和跟踪的原因.
Well, even if you have your root logger as TRACE, your log4j.logger.petascope
(pointing to INFO) will override the default root logger's TRACE for petascope.* packages, which is the reason you are not seeing any DEBUG and TRACE.
为简单起见,请尝试以下操作...将根记录器设置为跟踪:-
To keep things simple, try this... set the root logger to trace:-
log4j.rootLogger=TRACE, stdout
然后,注释掉以下几行:-
Then, comment out the following lines:-
#log4j.logger.petascope=INFO
#log4j.logger.petascope.wcps=DEBUG
#log4j.logger.petascope.wcst=DEBUG
#log4j.logger.petascope.wcs=DEBUG
#log4j.logger.petascope.wcs2=TRACE
让我知道这是否对您有用.
Let me know if that works for you.
这篇关于Log4j |更新Appender的日志级别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!