I just have finished adjustment of log4j2.xml configuration file and spotted something I don't really understand. So what is <Configuration status="SOME_STATUS_HERE">
?
我刚刚完成了log4j2.xml配置文件的调整,发现了一些我不太懂的东西。那么什么是
Almost in all examples here : http://logging.apache.org/log4j/2.x/manual/configuration.html folks from Apache added status to configuration.
几乎在这里的所有示例中:来自Apache的http://logging.apache.org/log4j/2.x/manual/configuration.html人员将状态添加到配置中。
For example here is the first one:
例如,这是第一个:
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="WARN"> <!--status="WARN" - what is this???-->
<Appenders>
<Console name="Console" target="SYSTEM_OUT">
<PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
</Console>
</Appenders>
<Loggers>
<Root level="error">
<AppenderRef ref="Console"/>
</Root>
</Loggers>
</Configuration>
3 个解决方案
#1
46
The status logger is used internally by log4j2 components. Setting status="debug"
(or "trace") in the configuration will cause this internal logging to be output to the command line.
状态记录器由log4j2组件在内部使用。在配置中设置status =“debug”(或“trace”)将导致此内部日志记录输出到命令行。
It will print debug information about which log4j2 plugin components are loaded (all configuration elements map to log4j2 plugins), and more details like for example what appenders and loggers were found, what parameters they have and how they are combined.
它将打印有关加载哪些log4j2插件组件的调试信息(所有配置元素映射到log4j2插件),以及更多详细信息,例如找到了哪些appender和logger,它们具有哪些参数以及它们如何组合。
This is useful for troubleshooting configuration issues.
这对于解决配置问题非常有用。
From Log4j 2.9, you can use system property log4j2.debug
(no value required) to turn on internal Log4j2 status logging even before the configuration file is loaded. Prior to version 2.9, the same can be achieved with system property -Dorg.apache.logging.log4j.simplelog.StatusLogger.level=TRACE
.
从Log4j 2.9开始,即使在加载配置文件之前,也可以使用系统属性log4j2.debug(无需任何值)打开内部Log4j2状态日志记录。在2.9版之前,使用系统属性-Dorg.apache.logging.log4j.simplelog.StatusLogger.level = TRACE可以实现相同的功能。
#2
22
In case someone is wondering where the Log4j2 XML <Configuration>
element attributes are mentioned in the Log4j2 documentation, I thought it could be useful to provide the link here. See also a snapshot of the attribute list below:
如果有人想知道Log4j2文档中提到Log4j2 XML
#3
4
And in case anyone is looking for the correct levels for the status attribute they're: "trace", "debug", "info", "warn", "error" and "fatal".
如果有人正在寻找状态属性的正确级别,他们就是:“跟踪”,“调试”,“信息”,“警告”,“错误”和“致命”。
Log4j2配置
#1
46
The status logger is used internally by log4j2 components. Setting status="debug"
(or "trace") in the configuration will cause this internal logging to be output to the command line.
状态记录器由log4j2组件在内部使用。在配置中设置status =“debug”(或“trace”)将导致此内部日志记录输出到命令行。
It will print debug information about which log4j2 plugin components are loaded (all configuration elements map to log4j2 plugins), and more details like for example what appenders and loggers were found, what parameters they have and how they are combined.
它将打印有关加载哪些log4j2插件组件的调试信息(所有配置元素映射到log4j2插件),以及更多详细信息,例如找到了哪些appender和logger,它们具有哪些参数以及它们如何组合。
This is useful for troubleshooting configuration issues.
这对于解决配置问题非常有用。
From Log4j 2.9, you can use system property log4j2.debug
(no value required) to turn on internal Log4j2 status logging even before the configuration file is loaded. Prior to version 2.9, the same can be achieved with system property -Dorg.apache.logging.log4j.simplelog.StatusLogger.level=TRACE
.
从Log4j 2.9开始,即使在加载配置文件之前,也可以使用系统属性log4j2.debug(无需任何值)打开内部Log4j2状态日志记录。在2.9版之前,使用系统属性-Dorg.apache.logging.log4j.simplelog.StatusLogger.level = TRACE可以实现相同的功能。
#2
22
In case someone is wondering where the Log4j2 XML <Configuration>
element attributes are mentioned in the Log4j2 documentation, I thought it could be useful to provide the link here. See also a snapshot of the attribute list below:
如果有人想知道Log4j2文档中提到Log4j2 XML
#3
4
And in case anyone is looking for the correct levels for the status attribute they're: "trace", "debug", "info", "warn", "error" and "fatal".
如果有人正在寻找状态属性的正确级别,他们就是:“跟踪”,“调试”,“信息”,“警告”,“错误”和“致命”。
Log4j2配置