gpt4 book ai didi

logging - 避免出现 log4j2 配置调试消息

转载 作者:行者123 更新时间:2023-12-04 11:25:57 24 4
gpt4 key购买 nike

我第一次尝试使用 log4j2。它根据我的配置进行日志记录,除了它还会向控制台输出类似配置调试消息的内容:

2013-08-07 19:36:50,870 DEBUG Generated plugins in 0.000029274 seconds
2013-08-07 19:36:50,871 DEBUG Generated plugins in 0.000028703 seconds
2013-08-07 19:36:50,871 DEBUG Generated plugins in 0.000022613 seconds
2013-08-07 19:36:50,872 DEBUG Generated plugins in 0.000017492 seconds
2013-08-07 19:36:50,872 DEBUG Generated plugins in 0.000017009 seconds
2013-08-07 19:36:50,873 DEBUG Generated plugins in 0.000025645 seconds
2013-08-07 19:36:50,873 DEBUG Generated plugins in 0.000017140 seconds
2013-08-07 19:36:50,873 DEBUG Generated plugins in 0.000017438 seconds
2013-08-07 19:36:50,874 DEBUG Generated plugins in 0.000018848 seconds
2013-08-07 19:36:50,874 DEBUG Generated plugins in 0.000018203 seconds
2013-08-07 19:36:50,875 DEBUG Generated plugins in 0.000017775 seconds
2013-08-07 19:36:50,875 DEBUG Generated plugins in 0.000018104 seconds
2013-08-07 19:36:50,876 DEBUG Generated plugins in 0.000017015 seconds
2013-08-07 19:36:50,876 DEBUG Generated plugins in 0.000018079 seconds
2013-08-07 19:36:50,890 DEBUG Calling createLayout on class org.apache.logging.log4j.core.layout.PatternLayout for element PatternLayout with params(pattern="%d{HH:mm:ss.SSS} %-5level %msg%n", Configuration(.../conf/preprocessor.log4j2.xml), null, charset="null", suppressExceptions="null")
2013-08-07 19:36:50,890 DEBUG Generated plugins in 0.000032718 seconds
2013-08-07 19:36:50,893 DEBUG Calling createAppender on class org.apache.logging.log4j.core.appender.ConsoleAppender for element Console with params(PatternLayout(%d{HH:mm:ss.SSS} %-5level %msg%n), null, target="SYSTEM_OUT", name="Console", follow="null", suppressExceptions="null")
2013-08-07 19:36:50,894 DEBUG Calling createLayout on class org.apache.logging.log4j.core.layout.PatternLayout for element PatternLayout with params(pattern="%d{MM-dd HH:mm:ss.SSS} %-5level %msg%n", Configuration(.../conf/preprocessor.log4j2.xml), null, charset="null", suppressExceptions="null")
2013-08-07 19:36:50,895 DEBUG Calling createPolicy on class org.apache.logging.log4j.core.appender.rolling.SizeBasedTriggeringPolicy for element SizeBasedTriggeringPolicy with params(size="10 MB")
2013-08-07 19:36:50,897 DEBUG Calling createPolicy on class org.apache.logging.log4j.core.appender.rolling.CompositeTriggeringPolicy for element Policies with params(policies={SizeBasedTriggeringPolicy(size=10485760)})
2013-08-07 19:36:50,900 DEBUG Calling createAppender on class org.apache.logging.log4j.core.appender.RollingFileAppender for element RollingFile with params(fileName="logs/preprocessor.log", filePattern="logs/preprocessor-%d{yyyy-MM-dd-HH}-%i.log.gz", append="null", name="RollingFileAll", bufferedIO="null", immediateFlush="null", Policies(CompositeTriggeringPolicy{SizeBasedTriggeringPolicy(size=10485760)}), null, PatternLayout(%d{MM-dd HH:mm:ss.SSS} %-5level %msg%n), null, suppressExceptions="null", advertise="null", advertiseURI="null", Configuration(..../conf/preprocessor.log4j2.xml))
2013-08-07 19:36:50,902 DEBUG Starting RollingFileManager logs/preprocessor.log
2013-08-07 19:36:50,904 DEBUG Generated plugins in 0.000022500 seconds
2013-08-07 19:36:50,906 DEBUG Calling createAppenders on class org.apache.logging.log4j.core.config.plugins.AppendersPlugin for element appenders with params(appenders={Console, RollingFileAll})
2013-08-07 19:36:50,906 DEBUG Generated plugins in 0.000019671 seconds
2013-08-07 19:36:50,908 DEBUG Calling createAppenderRef on class org.apache.logging.log4j.core.config.AppenderRef for element appender-ref with params(ref="Console", level="WARN", null)
2013-08-07 19:36:50,908 DEBUG Calling createAppenderRef on class org.apache.logging.log4j.core.config.AppenderRef for element appender-ref with params(ref="RollingFileAll", level="null", null)
2013-08-07 19:36:50,910 DEBUG Calling createLogger on class org.apache.logging.log4j.core.config.LoggerConfig for element logger with params(additivity="false", level="ERROR", name="eventLogger", includeLocation="null", appender-ref={org.apache.logging.log4j.core.config.AppenderRef@22b27cca, org.apache.logging.log4j.core.config.AppenderRef@741ec391}, properties={}, Configuration(.../conf/preprocessor.log4j2.xml), null)
2013-08-07 19:36:50,912 DEBUG Calling createAppenderRef on class org.apache.logging.log4j.core.config.AppenderRef for element appender-ref with params(ref="Console", level="INFO", null)
2013-08-07 19:36:50,913 DEBUG Calling createAppenderRef on class org.apache.logging.log4j.core.config.AppenderRef for element appender-ref with params(ref="RollingFileAll", level="null", null)
2013-08-07 19:36:50,915 DEBUG Calling createLogger on class org.apache.logging.log4j.core.config.LoggerConfig$RootLogger for element root with params(additivity="null", level="DEBUG", includeLocation="null", appender-ref={org.apache.logging.log4j.core.config.AppenderRef@72607cad, org.apache.logging.log4j.core.config.AppenderRef@1c997c85}, properties={}, Configuration(.../preprocessor.log4j2.xml), null)
2013-08-07 19:36:50,916 DEBUG Calling createLoggers on class org.apache.logging.log4j.core.config.plugins.LoggersPlugin for element loggers with params(loggers={eventLogger, root})

我的配置文件 preprocessor.log4j2.xml 看起来像:
<?xml version="1.0" encoding="UTF-8" ?>
<configuration status="DEBUG">
<appenders>

<Console name="Console" target="SYSTEM_OUT">
<PatternLayout pattern="%d{HH:mm:ss.SSS} %-5level %msg%n" />
</Console>

<RollingFile name="RollingFileAll" fileName="logs/preprocessor.log"
filePattern="logs/preprocessor-%d{yyyy-MM-dd-HH}-%i.log.gz">
<PatternLayout pattern="%d{MM-dd HH:mm:ss.SSS} %-5level %msg%n" />
<Policies>
<SizeBasedTriggeringPolicy size="10 MB" />
</Policies>
</RollingFile>

</appenders>
<loggers>
<root level="DEBUG">
<appender-ref ref="Console" level="INFO" />
<appender-ref ref="RollingFileAll" />
</root>
</loggers>
</configuration>

这就是我从 java 中配置(我知道自动配置)log4j2 的方式:
File file = new File(LOG4J2_CONF_FILE);
Configurator.initialize("preprocessor", null, file.toURI());

我曾尝试添加 EventLogger 记录器并禁用其输出,但没有帮助。您知道如何避免出现此配置调试消息吗?

预先感谢您提供任何提示。

最佳答案

只需删除 status="DEBUG"从配置标签

关于logging - 避免出现 log4j2 配置调试消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18122780/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com