问题描述
log4j有一个属性 log4j.debug
,这将有助于向用户提供实际用于配置日志记录系统的配置文件的指示。
log4j has a property, log4j.debug
, which will helpfully provide the user with an indication of which configuration file was actually used to configure the logging system.
我无法找到与(否则更优越的)Logback日志框架等效的东西。有没有办法在运行时打印(用于诊断目的),哪个配置文件Logback用于自举?
I haven't been able to find anything equivalent with the (otherwise superior) Logback logging framework. Is there any way to print (for diagnostic purposes) at runtime, which configuration file Logback used to bootstrap itself?
[edit]
为了澄清,我'理想情况下,像一个不需要我修改配置文件本身的解决方案(例如,由于错误组装的第三方JAR可能被错误地拾取,并且在我的回溯配置XML之前)。
[edit]To clarify, I'd ideally like a solution that doesn't require me to modify the configuration file itself (since a badly assembled third-party JAR, for example, may be picked up incorrectly, and prior to my logback configuration XML).
推荐答案
您可以设置Java系统属性以输出Logback调试信息:
You can set a Java system property to output Logback debugging info:
java -Dlogback.statusListenerClass=ch.qos.logback.core.status.OnConsoleStatusListener
的Logback文档进一步说明了这一点(非常底部)提到强制状态输出)和:
This is further explained by the Logback documentation for automatic status printing (very bottom mentions forcing status output) and the logback.statusListenerClass property:
这篇关于如何确定Logback实际使用的日志配置源?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!