Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/logging/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 停止日志4J2记录器初始化日志打印到标准输出_Java_Logging_Configuration_Log4j_Log4j2 - Fatal编程技术网

Java 停止日志4J2记录器初始化日志打印到标准输出

Java 停止日志4J2记录器初始化日志打印到标准输出,java,logging,configuration,log4j,log4j2,Java,Logging,Configuration,Log4j,Log4j2,下面是log4j2.xml配置文件 <?xml version="1.0" encoding="UTF-8"?> <Configuration status="DEBUG"> <Properties> <Property name="log-path">C:/logs</Property> </Properties> <Appenders> <RollingFile name="

下面是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.