为什么 Tomcat 将 catalina.out 日志文件中的日志行加倍?
每次查看 Tomcat 的 catalina.out
日志文件时,我都会看到每个日志条目都有双行。 为什么会发生这种情况? Java (Tomcat) 用户以前是否遇到过这种情况?
Every time I look at Tomcat's catalina.out
log file, I see double lines for every log entry. Why is this happening? Has this happen before to any Java (Tomcat) users?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
检查您的 log4j 以确保您没有“双重追加”到您的记录器。 您的根记录器已经有一个与之关联的附加程序,如果您要过滤其他类别,请确保不指定附加程序,除非您希望它转到除根之外的附加程序。
Check your log4j to make sure you are not "double appending" to your logger. Your root logger already has an appender associated with it and if you are filtering an additional category make sure you don't specify an appender unless you want it to go to an appender other than the root.
当我在类路径上有 2 个 log4j.properties 副本时,就会发生这种情况。
检查多个日志记录配置
This happens to me when i have 2 copies of log4j.properties on the classpath.
Check for multiple logging configurations
您的 web 应用程序的 log4j.properties 是否设置为登录到 catalina.out? Tomcat 已经在那里记录事件,如果您的应用程序也在那里记录,这可能可以解释双重条目。
Is your webapp's log4j.properties set to log to catalina.out? Tomcat already logs events there and if your application also logs there, that would probably explain the doubled entries.
它很可能与罐子的加载顺序有关。 在我参与的一个较旧的项目中,这种情况会一直发生,解决方案是以“完美”的顺序重新排列罐子,事情就会自行修复。
它可能不仅仅是多个 log4j,还可能是 commons-logging、slf4j 等。尝试重新排列它们,但如果没有看到您的类路径顺序,就很难提供进一步的帮助。
It most likely has something to do with the order the jars are loaded. On an older project I was on, this would happen all the time, the solution was to reorder the jars in the "perfect" order and things would fix themselves.
It might not just be multiple log4j's, but commons-logging, slf4j, etc. Try rearranging them, but without seeing your classpath ordering, it's hard to help any further.
我遇到了同样的问题。 像这样:
只需将
log4j.rootLogger=info,R
设置为log4j.rootLogger=R
然后就可以了!I got the same problem. like this:
JUST set
log4j.rootLogger=info,R
tolog4j.rootLogger=R
then it works!