简体   繁体   English

Log4j多线程

[英]Log4j Multiple Threads

I am adding ConsoleAppender to rootlogger for log4j as 我将ConsoleAppender添加到rootlogger的log4j作为

BasicConfigurator.configure(new ConsoleAppender(layout, "System.err"));

But somehow log messages in some loggers down the hierarchy are not reaching console. 但是不知何故,层次结构中某些记录器中的日志消息未到达控制台。 I have not seen any instance in the hierarchy setting the additivity flag as false. 我没有在层次结构中看到将可加性标志设置为false的任何实例。

Some loggers are running in different threads, do you I need to do any configuration? 有些记录器在不同的线程中运行,您是否需要进行任何配置? How can I debug this? 我该如何调试?

Log4j is thread-safe. Log4j是线程安全的。 See Is log4j thread-safe? 请参阅log4j线程安全吗? . You should not need any special configuration for multi-threading. 对于多线程,您不需要任何特殊的配置。

However, the messages can appear in a mixed-up order from different threads, so check that they aren't somewhere else in the logs. 但是,这些消息可能以不同的顺序出现在不同的线程中,因此请检查它们是否不在日志中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM