log4j 和 Commons Logging 共存
在我的应用程序中,我使用 log4j 和一些第三方 jar。其中第 3 方 jar 之一正在使用 Commons Logging。现在,每当我使用第三方 jar 中的类时,日志消息都会以某种方式由两个单独的附加程序处理。 例如:
在我的 log4j.properties 中我已指定:
- log4j.logger.myClass=DEBUG, serverFile, defaultSTDOUT,其中 serverFile 是 org.apache.log4j.RollingFileAppender,defaultSTDOUT 是 org.apache.log4j.ConsoleAppender
我的代码我做 Logger logger = Logger.getLogger(myClass.class) 然后我像 logger.debug("debug message")
in console I see
DEBUG [2009-10-14 16:08:34,415] - debug message
51215 [Thread- 13] DEBUG myClass - 调试消息
第一行是我的,第二行可能是因为第三方 jar 的缘故。 如何确保只显示我的日志消息?
In my application I'm using log4j and some 3rd party jars. One of those 3rd party jars is using Commons Logging. Now whenever I use classes from that 3rd party jar, somehow the log message is handled by two separate appenders.
For example:
in my log4j.properties I have specified:
- log4j.logger.myClass=DEBUG, serverFile, defaultSTDOUT, where serverFile is a org.apache.log4j.RollingFileAppender and defaultSTDOUT is org.apache.log4j.ConsoleAppender
in my code I do Logger logger = Logger.getLogger(myClass.class) and then I ue it like logger.debug("debug message")
in console I see
DEBUG [2009-10-14 16:08:34,415] - debug message
51215 [Thread-13] DEBUG myClass - debug message
The first line is mine and the second line is probably there because of that 3rd party jar.
How can I ensure that only my log message are shown?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看来为我的记录器指定 log4j.additivity 就完成了这项工作。
It seems that specifying log4j.additivity for my logger did the job.