Log4j 2.如何获取log4j的调试消息? [英] Log4j 2. How get log4j's debug messages?
问题描述
据我了解,log4j可以处理系统属性-Dlog4j.debug.如果使用它运行应用程序,则将获得log4j的调试输出.
As far as i understand log4j can handle system property -Dlog4j.debug. If you run your app with it you will get log4j's debug output.
示例:java -Dlog4j.debug -jar test.jar
Example: java -Dlog4j.debug -jar test.jar
log4j 2是否有类似的东西?
Is there something similar for log4j 2?
推荐答案
2018年1月更新:
Update January 2018:
从Log4j 2.10开始,这很容易:只需使用系统属性 log4j2.debug
(无需任何值;可以使用空字符串)运行程序.
From Log4j 2.10, this is easy: just run your program with system property log4j2.debug
(no value needed; an empty string is fine).
关于状态记录器的当前 (log4j-2.1) 文档有点混乱.基本上:
The current (log4j-2.1) documentation on the status logger is a bit confusing. Basically:
- 在找到配置之前,可以使用系统属性
org.apache.logging.log4j.simplelog.StatusLogger.level
控制状态记录器级别. - 找到配置后,可以使用"status"属性在配置文件中控制状态记录器级别,例如:
< Configuration status ="trace">
.
- Until a configuration is found, status logger level can be controlled with system property
org.apache.logging.log4j.simplelog.StatusLogger.level
. - After a configuration is found, status logger level can be controlled in the configuration file with the "status" attribute, for example:
<Configuration status="trace">
.
更新:文档在log4j-2.2中得到了改进
UPDATE: the documentation was improved in log4j-2.2.
这篇关于Log4j 2.如何获取log4j的调试消息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!