gpt4 book ai didi

java - 停止 log4j2 记录器初始化日志打印到标准输出

转载 作者:行者123 更新时间:2023-12-05 02:20:31 25 4
gpt4 key购买 nike

下面是log4j2.xml配置文件

<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="DEBUG">
<Properties>
<Property name="log-path">C:/logs</Property>
</Properties>
<Appenders>
<RollingFile name="RollingFile" fileName="${log-path}/myexample.log"
filePattern="${log-path}/myexample-%d{yyyy-MM-dd}-%i.log" >
<PatternLayout>
<pattern>%d{dd/MMM/yyyy HH:mm:ss,SSS}- %c{1}: %m%n</pattern>
</PatternLayout>
<Policies>
<SizeBasedTriggeringPolicy size="1 KB" />
</Policies>
<DefaultRolloverStrategy max="4"/>
</RollingFile>
</Appenders>
<Loggers>
<Logger name="root" level="debug" additivity="false">
<appender-ref ref="RollingFile" level="debug"/>
</Logger>
</Loggers>
</Configuration>

以下输出被打印到标准输出。

2016-08-22 19:21:59,384 main DEBUG Initializing configuration XmlConfiguration[location=jar:file:/C:/demo-program-1.0-SNAPSHOT.jar!/log4j2.xml]
2016-08-22 19:21:59,415 main DEBUG Installed script engines
2016-08-22 19:22:00,509 main DEBUG Oracle Nashorn Version: 1.8.0_101, Language: ECMAScript, Threading: Not Thread Safe, Compile: true, Names: {nashorn, Nashorn, js, JS, JavaScript, javascript, ECMAScript, ecmascript}
2016-08-22 19:22:00,509 main DEBUG PluginManager 'Core' found 99 plugins
2016-08-22 19:22:00,509 main DEBUG PluginManager 'Level' found 0 plugins
2016-08-22 19:22:00,524 main DEBUG No scheduled items
2016-08-22 19:22:00,524 main DEBUG Building Plugin[name=property, class=org.apache.logging.log4j.core.config.Property].
2016-08-22 19:22:00,540 main DEBUG PluginManager 'TypeConverter' found 23 plugins
2016-08-22 19:22:00,571 main DEBUG createProperty(name="log-path", value="C:/logs")
2016-08-22 19:22:00,571 main DEBUG Building Plugin[name=properties, class=org.apache.logging.log4j.core.config.PropertiesPlugin].
2016-08-22 19:22:00,571 main DEBUG configureSubstitutor(={log-path=C:/logs}, Configuration(jar:file:/C:/demo-program-1.0-SNAPSHOT.jar!/log4j2.xml))
2016-08-22 19:22:00,587 main DEBUG PluginManager 'Lookup' found 13 plugins
2016-08-22 19:22:00,587 main DEBUG Building Plugin[name=layout, class=org.apache.logging.log4j.core.layout.PatternLayout].
2016-08-22 19:22:00,587 main DEBUG PatternLayout$Builder(pattern="%d{dd/MMM/yyyy HH:mm:ss,SSS}- %c{1}: %m%n", PatternSelector=null, Configuration(jar:file:/C:/demo-program-1.0-SNAPSHOT.jar!/log4j2.xml), Replace=null, charset="null", alwaysWriteExceptions="null", noConsoleNoAnsi="null", header="null", footer="null")
2016-08-22 19:22:00,587 main DEBUG PluginManager 'Converter' found 41 plugins
2016-08-22 19:22:00,634 main DEBUG Building Plugin[name=SizeBasedTriggeringPolicy, class=org.apache.logging.log4j.core.appender.rolling.SizeBasedTriggeringPolicy].
2016-08-22 19:22:00,649 main DEBUG createPolicy(size="1 KB")
2016-08-22 19:22:00,649 main DEBUG Building Plugin[name=Policies, class=org.apache.logging.log4j.core.appender.rolling.CompositeTriggeringPolicy].
2016-08-22 19:22:00,649 main DEBUG createPolicy(={SizeBasedTriggeringPolicy(size=1024)})
2016-08-22 19:22:00,649 main DEBUG Building Plugin[name=DefaultRolloverStrategy, class=org.apache.logging.log4j.core.appender.rolling.DefaultRolloverStrategy].
2016-08-22 19:22:00,665 main DEBUG createStrategy(max="4", min="null", fileIndex="null", compressionLevel="null", ={}, stopCustomActionsOnError="true", Configuration(jar:file:/C:/demo-program-1.0-SNAPSHOT.jar!/log4j2.xml))
2016-08-22 19:22:00,665 main DEBUG Building Plugin[name=appender, class=org.apache.logging.log4j.core.appender.RollingFileAppender].
2016-08-22 19:22:00,680 main DEBUG createAppender(fileName="C:/logs/myexample.log", filePattern="C:/logs/myexample-%d{yyyy-MM-dd}-%i.log", append="null", name="RollingFile", bufferedIO="null", bufferSize="null", immediateFlush="null", Policies(CompositeTriggeringPolicy(policies=[SizeBasedTriggeringPolicy(size=1024)])), DefaultRolloverStrategy(DefaultRolloverStrategy(min=1, max=4)), PatternLayout(%d{dd/MMM/yyyy HH:mm:ss,SSS}- %c{1}: %m%n), Filter=null, ignoreExceptions="null", advertise="null", advertiseURI="null", Configuration(jar:file:/C:/demo-program-1.0-SNAPSHOT.jar!/log4j2.xml))
2016-08-22 19:22:00,696 main DEBUG Starting RollingFileManager C:/logs/myexample.log
2016-08-22 19:22:00,696 main DEBUG PluginManager 'FileConverter' found 2 plugins
2016-08-22 19:22:00,696 main DEBUG Building Plugin[name=appenders, class=org.apache.logging.log4j.core.config.AppendersPlugin].
2016-08-22 19:22:00,712 main DEBUG createAppenders(={RollingFile})
2016-08-22 19:22:00,712 main DEBUG Building Plugin[name=appender-ref, class=org.apache.logging.log4j.core.config.AppenderRef].
2016-08-22 19:22:00,712 main DEBUG createAppenderRef(ref="RollingFile", level="DEBUG", Filter=null)
2016-08-22 19:22:00,712 main DEBUG Building Plugin[name=logger, class=org.apache.logging.log4j.core.config.LoggerConfig].
2016-08-22 19:22:00,727 main DEBUG createLogger(additivity="false", level="DEBUG", name="root", includeLocation="null", ={RollingFile}, ={}, Configuration(jar:file:/C:/demo-program-1.0-SNAPSHOT.jar!/log4j2.xml), Filter=null)
2016-08-22 19:22:00,727 main DEBUG Building Plugin[name=loggers, class=org.apache.logging.log4j.core.config.LoggersPlugin].
2016-08-22 19:22:00,727 main DEBUG createLoggers(={root})
2016-08-22 19:22:00,743 main DEBUG Configuration XmlConfiguration[location=jar:file:/C:/demo-program-1.0-SNAPSHOT.jar!/log4j2.xml] initialized
2016-08-22 19:22:00,743 main DEBUG Starting configuration XmlConfiguration[location=jar:file:/C:/demo-program-1.0-SNAPSHOT.jar!/log4j2.xml]
2016-08-22 19:22:00,743 main DEBUG Started configuration XmlConfiguration[location=jar:file:/C:/demo-program-1.0-SNAPSHOT.jar!/log4j2.xml] OK.
2016-08-22 19:22:00,743 main DEBUG Shutting down OutputStreamManager SYSTEM_OUT.false.false-1
2016-08-22 19:22:00,759 main DEBUG Stopped org.apache.logging.log4j.core.config.DefaultConfiguration@68de145 OK
2016-08-22 19:22:00,915 main DEBUG Registering MBean org.apache.logging.log4j2:type=c387f44
2016-08-22 19:22:00,930 main DEBUG Registering MBean org.apache.logging.log4j2:type=c387f44,component=StatusLogger
2016-08-22 19:22:00,930 main DEBUG Registering MBean org.apache.logging.log4j2:type=c387f44,component=ContextSelector
2016-08-22 19:22:00,930 main DEBUG Registering MBean org.apache.logging.log4j2:type=c387f44,component=Loggers,name=
2016-08-22 19:22:00,930 main DEBUG Registering MBean org.apache.logging.log4j2:type=c387f44,component=Appenders,name=RollingFile
2016-08-22 19:22:00,946 main DEBUG Reconfiguration complete for context[name=c387f44] at URI jar:file:/C:/demo-program-1.0-SNAPSHOT.jar!/log4j2.xml (org.apache.logging.log4j.core.LoggerContext@333291e3) with optional ClassLoader: null
2016-08-22 19:22:00,946 main DEBUG Shutdown hook enabled. Registering a new one.
2016-08-22 19:22:00,946 main DEBUG LoggerContext[name=c387f44, org.apache.logging.log4j.core.LoggerContext@333291e3] started OK.

为什么要打印这些初始化语句?

最佳答案

在配置的第一行中将状态记录器级别从 DEBUG 更改为 WARN。

关于java - 停止 log4j2 记录器初始化日志打印到标准输出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39094277/

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