log4j2不会打印在线程

时间:2016-07-19 13:25:36

标签: java log4j2

我很惊讶log4j2在线程中执行时不会打印消息。

详情

  • log4j2版本2.6.2
  • 调试和运行时受影响
  • 两个标准appender(文件,控制台)
  • 调用LOG.error("msg");LOG.error("msg", e);LOG.info("bad news", e);
  • 单独的线程中运行,并且所有后续的LOG调用均未显示
  • Eclipse Mars Release(4.5.0)
  • Java JDK 1.8.0_51
  • Maven 3.x项目,但是从Eclipse开始
  • 赢7(专业)

初始化

private static final Logger LOG = LogManager.getLogger(MainProcess.class);

配置

<?xml version="1.0" encoding="UTF-8"?>
<Configuration xmlns="http://logging.apache.org/log4j/2.0/config" packages="xyz.my.appenders">
<Appenders>
    <File name="file" fileName="logfile.log" append="true">
        <PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss.SSS} [%t] [%p] %C{2} (%F:%L) - %m%n"/>
    </File>
    <Console name="console" target="SYSTEM_OUT">
        <PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss.SSS} [%t] [%p] %C{2} (%F:%L) - %m%n"/>
    </Console>
    <LimitAppender name="log-viewer" numberOfLines="30">
        <PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss.SSS} [%t] [%p] %C{2} (%F:%L) - %m%n"/>
    </LimitAppender>
</Appenders>
<Loggers>
    <Logger name="xyz.my.application" level="DEBUG"/>
    <Root level="DEBUG">
        <AppenderRef ref="console"/>
        <AppenderRef ref="file"/>
        <!-- <AppenderRef ref="log-viewer"/> -->
    </Root>
</Loggers>
</Configuration>

跟踪log4j2 (283行中的200个)

2016-07-20 09:42:14,396 main DEBUG Initializing configuration XmlConfiguration[location=C:\...\TheProject\target\classes\log4j2.xml]
2016-07-20 09:42:14,409 main DEBUG Installed script engines
2016-07-20 09:42:15,040 main DEBUG Oracle Nashorn Version: 1.8.0_51, Language: ECMAScript, Threading: Not Thread Safe, Compile: true, Names: {nashorn, Nashorn, js, JS, JavaScript, javascript, ECMAScript, ecmascript}
2016-07-20 09:42:15,115 main DEBUG Took 0.074225 seconds to load 1 plugins from package xyz.my.appenders
2016-07-20 09:42:15,115 main DEBUG PluginManager 'Core' found 100 plugins
2016-07-20 09:42:15,116 main DEBUG PluginManager 'Level' found 0 plugins
2016-07-20 09:42:15,119 main DEBUG No scheduled items
2016-07-20 09:42:15,119 main DEBUG PluginManager 'Lookup' found 13 plugins
2016-07-20 09:42:15,121 main DEBUG Building Plugin[name=layout, class=org.apache.logging.log4j.core.layout.PatternLayout].
2016-07-20 09:42:15,132 main TRACE TypeConverterRegistry initializing.
2016-07-20 09:42:15,132 main DEBUG PluginManager 'TypeConverter' found 23 plugins
2016-07-20 09:42:15,144 main DEBUG PatternLayout$Builder(pattern="%d{yyyy-MM-dd HH:mm:ss.SSS} [%t] [%p] %C{2} (%F:%L) - %m%n", PatternSelector=null, Configuration(C:\...\TheProject\target\classes\log4j2.xml), Replace=null, charset="null", alwaysWriteExceptions="null", noConsoleNoAnsi="null", header="null", footer="null")
2016-07-20 09:42:15,145 main DEBUG PluginManager 'Converter' found 41 plugins
2016-07-20 09:42:15,179 main DEBUG Building Plugin[name=appender, class=org.apache.logging.log4j.core.appender.FileAppender].
2016-07-20 09:42:15,185 main DEBUG createAppender(fileName="logfile.log", append="true", locking="null", name="file", immediateFlush="null", ignoreExceptions="null", bufferedIo="null", bufferSize="null", PatternLayout(%d{yyyy-MM-dd HH:mm:ss.SSS} [%t] [%p] %C{2} (%F:%L) - %m%n), Filter=null, advertise="null", advertiseUri="null", Configuration(C:\...\TheProject\target\classes\log4j2.xml))
2016-07-20 09:42:15,189 main DEBUG Starting FileManager logfile.log
2016-07-20 09:42:15,189 main DEBUG Building Plugin[name=layout, class=org.apache.logging.log4j.core.layout.PatternLayout].
2016-07-20 09:42:15,190 main DEBUG PatternLayout$Builder(pattern="%d{yyyy-MM-dd HH:mm:ss.SSS} [%t] [%p] %C{2} (%F:%L) - %m%n", PatternSelector=null, Configuration(C:\...\TheProject\target\classes\log4j2.xml), Replace=null, charset="null", alwaysWriteExceptions="null", noConsoleNoAnsi="null", header="null", footer="null")
2016-07-20 09:42:15,190 main DEBUG Building Plugin[name=appender, class=org.apache.logging.log4j.core.appender.ConsoleAppender].
2016-07-20 09:42:15,192 main DEBUG Not in a ServletContext environment, thus not loading WebLookup plugin.
2016-07-20 09:42:15,193 main DEBUG PluginManager 'Converter' found 41 plugins
2016-07-20 09:42:15,194 main DEBUG Jansi is not installed, cannot find org.fusesource.jansi.WindowsAnsiOutputStream
2016-07-20 09:42:15,194 main DEBUG Starting OutputStreamManager SYSTEM_OUT.false-2
2016-07-20 09:42:15,202 main DEBUG ConsoleAppender$Builder(PatternLayout(%d{yyyy-MM-dd HH:mm:ss.SSS} [%t] [%p] %C{2} (%F:%L) - %m%n), Filter=null, target="SYSTEM_OUT", name="console", follow="null", ignoreExceptions="null")
2016-07-20 09:42:15,203 main DEBUG Jansi is not installed, cannot find org.fusesource.jansi.WindowsAnsiOutputStream
2016-07-20 09:42:15,204 main DEBUG Starting OutputStreamManager SYSTEM_OUT.false
2016-07-20 09:42:15,204 main DEBUG Building Plugin[name=layout, class=org.apache.logging.log4j.core.layout.PatternLayout].
2016-07-20 09:42:15,204 main DEBUG PatternLayout$Builder(pattern="%d{yyyy-MM-dd HH:mm:ss.SSS} [%t] [%p] %C{2} (%F:%L) - %m%n", PatternSelector=null, Configuration(C:\...\TheProject\target\classes\log4j2.xml), Replace=null, charset="null", alwaysWriteExceptions="null", noConsoleNoAnsi="null", header="null", footer="null")
2016-07-20 09:42:15,205 main DEBUG Building Plugin[name=appender, class=xyz.my.appenders.LimitMemoryAppender].
2016-07-20 09:42:15,205 main DEBUG createAppender(name="log-viewer", PatternLayout(%d{yyyy-MM-dd HH:mm:ss.SSS} [%t] [%p] %C{2} (%F:%L) - %m%n), numberOfLines="30")
2016-07-20 09:42:15,206 main DEBUG Building Plugin[name=appenders, class=org.apache.logging.log4j.core.config.AppendersPlugin].
2016-07-20 09:42:15,207 main DEBUG createAppenders(={file, console, log-viewer})
2016-07-20 09:42:15,207 main DEBUG Building Plugin[name=logger, class=org.apache.logging.log4j.core.config.LoggerConfig].
2016-07-20 09:42:15,210 main DEBUG createLogger(additivity="true", level="DEBUG", name="xyz.my.project", includeLocation="null", ={}, ={}, Configuration(C:\...\TheProject\target\classes\log4j2.xml), Filter=null)
2016-07-20 09:42:15,213 main DEBUG Building Plugin[name=AppenderRef, class=org.apache.logging.log4j.core.config.AppenderRef].
2016-07-20 09:42:15,214 main DEBUG createAppenderRef(ref="console", level="null", Filter=null)
2016-07-20 09:42:15,214 main DEBUG Building Plugin[name=AppenderRef, class=org.apache.logging.log4j.core.config.AppenderRef].
2016-07-20 09:42:15,214 main DEBUG createAppenderRef(ref="file", level="null", Filter=null)
2016-07-20 09:42:15,214 main DEBUG Building Plugin[name=AppenderRef, class=org.apache.logging.log4j.core.config.AppenderRef].
2016-07-20 09:42:15,215 main DEBUG createAppenderRef(ref="log-viewer", level="null", Filter=null)
2016-07-20 09:42:15,215 main DEBUG Building Plugin[name=root, class=org.apache.logging.log4j.core.config.LoggerConfig$RootLogger].
2016-07-20 09:42:15,216 main DEBUG createLogger(additivity="null", level="DEBUG", includeLocation="null", ={console, file, log-viewer}, ={}, Configuration(C:\...\TheProject\target\classes\log4j2.xml), Filter=null)
2016-07-20 09:42:15,217 main DEBUG Building Plugin[name=loggers, class=org.apache.logging.log4j.core.config.LoggersPlugin].
2016-07-20 09:42:15,217 main DEBUG createLoggers(={xyz.my.project, root})
2016-07-20 09:42:15,219 main DEBUG Configuration XmlConfiguration[location=C:\...\TheProject\target\classes\log4j2.xml] initialized
2016-07-20 09:42:15,219 main DEBUG Starting configuration XmlConfiguration[location=C:\...\TheProject\target\classes\log4j2.xml]
2016-07-20 09:42:15,219 main DEBUG Started configuration XmlConfiguration[location=C:\...\TheProject\target\classes\log4j2.xml] OK.
2016-07-20 09:42:15,220 main TRACE Stopping org.apache.logging.log4j.core.config.DefaultConfiguration@26a1ab54...
2016-07-20 09:42:15,220 main TRACE DefaultConfiguration notified 1 ReliabilityStrategies that config will be stopped.
2016-07-20 09:42:15,221 main TRACE DefaultConfiguration stopping root LoggerConfig.
2016-07-20 09:42:15,221 main TRACE DefaultConfiguration notifying ReliabilityStrategies that appenders will be stopped.
2016-07-20 09:42:15,222 main TRACE DefaultConfiguration stopping remaining Appenders.
2016-07-20 09:42:15,222 main DEBUG Shutting down OutputStreamManager SYSTEM_OUT.false-1
2016-07-20 09:42:15,222 main TRACE DefaultConfiguration stopped 1 remaining Appenders.
2016-07-20 09:42:15,222 main TRACE DefaultConfiguration cleaning Appenders from 1 LoggerConfigs.
2016-07-20 09:42:15,222 main DEBUG Stopped org.apache.logging.log4j.core.config.DefaultConfiguration@26a1ab54 OK
2016-07-20 09:42:15,295 main TRACE Reregistering MBeans after reconfigure. Selector=org.apache.logging.log4j.core.selector.ClassLoaderContextSelector@74e52ef6
2016-07-20 09:42:15,295 main TRACE Reregistering context (1/1): 'c387f44' org.apache.logging.log4j.core.LoggerContext@6ed3ccb2
2016-07-20 09:42:15,297 main TRACE Unregistering but no MBeans found matching 'org.apache.logging.log4j2:type=c387f44'
2016-07-20 09:42:15,297 main TRACE Unregistering but no MBeans found matching 'org.apache.logging.log4j2:type=c387f44,component=StatusLogger'
2016-07-20 09:42:15,298 main TRACE Unregistering but no MBeans found matching 'org.apache.logging.log4j2:type=c387f44,component=ContextSelector'
2016-07-20 09:42:15,298 main TRACE Unregistering but no MBeans found matching 'org.apache.logging.log4j2:type=c387f44,component=Loggers,name=*'
2016-07-20 09:42:15,298 main TRACE Unregistering but no MBeans found matching 'org.apache.logging.log4j2:type=c387f44,component=Appenders,name=*'
2016-07-20 09:42:15,299 main TRACE Unregistering but no MBeans found matching 'org.apache.logging.log4j2:type=c387f44,component=AsyncAppenders,name=*'
2016-07-20 09:42:15,299 main TRACE Unregistering but no MBeans found matching 'org.apache.logging.log4j2:type=c387f44,component=AsyncLoggerRingBuffer'
2016-07-20 09:42:15,299 main TRACE Unregistering but no MBeans found matching 'org.apache.logging.log4j2:type=c387f44,component=Loggers,name=*,subtype=RingBuffer'
2016-07-20 09:42:15,301 main DEBUG Registering MBean org.apache.logging.log4j2:type=c387f44
2016-07-20 09:42:15,303 main DEBUG Registering MBean org.apache.logging.log4j2:type=c387f44,component=StatusLogger
2016-07-20 09:42:15,305 main DEBUG Registering MBean org.apache.logging.log4j2:type=c387f44,component=ContextSelector
2016-07-20 09:42:15,307 main DEBUG Registering MBean org.apache.logging.log4j2:type=c387f44,component=Loggers,name=
2016-07-20 09:42:15,308 main DEBUG Registering MBean org.apache.logging.log4j2:type=c387f44,component=Loggers,name=xyz.my.myproject
2016-07-20 09:42:15,309 main DEBUG Registering MBean org.apache.logging.log4j2:type=c387f44,component=Appenders,name=console
2016-07-20 09:42:15,310 main DEBUG Registering MBean org.apache.logging.log4j2:type=c387f44,component=Appenders,name=file
2016-07-20 09:42:15,310 main DEBUG Registering MBean org.apache.logging.log4j2:type=c387f44,component=Appenders,name=log-viewer
2016-07-20 09:42:15,312 main TRACE Using default SystemClock for timestamps.
2016-07-20 09:42:15,312 main TRACE Using DummyNanoClock for nanosecond timestamps.
2016-07-20 09:42:15,312 main DEBUG Reconfiguration complete for context[name=c387f44] at URI C:\...\TheProject\target\classes\log4j2.xml (org.apache.logging.log4j.core.LoggerContext@6ed3ccb2) with optional ClassLoader: null
2016-07-20 09:42:15,313 main DEBUG Shutdown hook enabled. Registering a new one.
2016-07-20 09:42:15,314 main DEBUG LoggerContext[name=c387f44, org.apache.logging.log4j.core.LoggerContext@6ed3ccb2] started OK.
2016-07-20 09:42:15.501 [main] [DEBUG] main.SQLHelperMain (SQLHelperMain.java:95) - Adding icon
2016-07-20 09:42:16.168 [Thread-2] [INFO] main.SQLHelperMain (SQLHelperMain.java:390) - SQLHelperMain.parsingFinished(true)
2016-07-20 09:42:16.424 [main] [DEBUG] main.SQLHelperMain (SQLHelperMain.java:82) - Open SQLHelperUI
2016-07-20 09:42:17,652 main DEBUG Stopping LoggerContext[name=c387f44, org.apache.logging.log4j.core.LoggerContext@6ed3ccb2]...
2016-07-20 09:42:17,653 main TRACE Unregistering 1 MBeans: [org.apache.logging.log4j2:type=c387f44]
2016-07-20 09:42:17,654 main TRACE Unregistering 1 MBeans: [org.apache.logging.log4j2:type=c387f44,component=StatusLogger]
2016-07-20 09:42:17,654 main TRACE Unregistering 1 MBeans: [org.apache.logging.log4j2:type=c387f44,component=ContextSelector]
2016-07-20 09:42:17,654 main TRACE Unregistering 2 MBeans: [org.apache.logging.log4j2:type=c387f44,component=Loggers,name=xyz.my.project, org.apache.logging.log4j2:type=c387f44,component=Loggers,name=]
2016-07-20 09:42:17,655 main TRACE Unregistering 3 MBeans: [org.apache.logging.log4j2:type=c387f44,component=Appenders,name=console, org.apache.logging.log4j2:type=c387f44,component=Appenders,name=file, org.apache.logging.log4j2:type=c387f44,component=Appenders,name=log-viewer]
2016-07-20 09:42:17,655 main TRACE Unregistering but no MBeans found matching 'org.apache.logging.log4j2:type=c387f44,component=AsyncAppenders,name=*'
2016-07-20 09:42:17,656 main TRACE Unregistering but no MBeans found matching 'org.apache.logging.log4j2:type=c387f44,component=AsyncLoggerRingBuffer'
2016-07-20 09:42:17,657 main TRACE Unregistering but no MBeans found matching 'org.apache.logging.log4j2:type=c387f44,component=Loggers,name=*,subtype=RingBuffer'
2016-07-20 09:42:17,657 main TRACE Stopping XmlConfiguration[location=C:\...\TheProject\target\classes\log4j2.xml]...
2016-07-20 09:42:17,658 main TRACE XmlConfiguration notified 3 ReliabilityStrategies that config will be stopped.
2016-07-20 09:42:17,658 main TRACE XmlConfiguration stopping 2 LoggerConfigs.
2016-07-20 09:42:17,658 main TRACE XmlConfiguration stopping root LoggerConfig.
2016-07-20 09:42:17,658 main TRACE XmlConfiguration notifying ReliabilityStrategies that appenders will be stopped.
2016-07-20 09:42:17,658 main TRACE XmlConfiguration stopping remaining Appenders.
2016-07-20 09:42:17,658 main DEBUG Shutting down FileManager logfile.log
2016-07-20 09:42:17,659 main DEBUG Shutting down OutputStreamManager SYSTEM_OUT.false
2016-07-20 09:42:17,659 main TRACE XmlConfiguration stopped 3 remaining Appenders.
2016-07-20 09:42:17,659 main TRACE XmlConfiguration cleaning Appenders from 3 LoggerConfigs.
2016-07-20 09:42:17,659 main DEBUG Stopped XmlConfiguration[location=C:\...\TheProject\target\classes\log4j2.xml] OK
2016-07-20 09:42:17,660 main DEBUG Stopped LoggerContext[name=c387f44, org.apache.logging.log4j.core.LoggerContext@6ed3ccb2]...
2016-07-20 09:42:27,713 AWT-EventQueue-0 DEBUG Not in a ServletContext environment, thus not loading WebLookup plugin.
2016-07-20 09:42:27,713 AWT-EventQueue-0 DEBUG PluginManager 'Converter' found 41 plugins
2016-07-20 09:42:27,715 AWT-EventQueue-0 DEBUG Jansi is not installed, cannot find org.fusesource.jansi.WindowsAnsiOutputStream
2016-07-20 09:42:27,715 AWT-EventQueue-0 DEBUG Starting OutputStreamManager SYSTEM_OUT.false-3
2016-07-20 09:42:27,716 AWT-EventQueue-0 DEBUG Starting LoggerContext[name=c387f44, org.apache.logging.log4j.core.LoggerContext@35644357]...
2016-07-20 09:42:27,716 AWT-EventQueue-0 DEBUG Reconfiguration started for context[name=c387f44] at URI null (org.apache.logging.log4j.core.LoggerContext@35644357) with optional ClassLoader: null
2016-07-20 09:42:27,716 AWT-EventQueue-0 DEBUG Using configurationFactory org.apache.logging.log4j.core.config.ConfigurationFactory$Factory@4d399216
2016-07-20 09:42:27,716 AWT-EventQueue-0 TRACE Trying to find [log4j2-testc387f44.properties] using context class loader sun.misc.Launcher$AppClassLoader@c387f44.
2016-07-20 09:42:27,717 AWT-EventQueue-0 TRACE Trying to find [log4j2-testc387f44.properties] using sun.misc.Launcher$AppClassLoader@c387f44 class loader.
2016-07-20 09:42:27,717 AWT-EventQueue-0 TRACE Trying to find [log4j2-testc387f44.properties] using sun.misc.Launcher$AppClassLoader@c387f44 class loader.
2016-07-20 09:42:27,718 AWT-EventQueue-0 TRACE Trying to find [log4j2-testc387f44.properties] using ClassLoader.getSystemResource().
2016-07-20 09:42:27,718 AWT-EventQueue-0 TRACE Trying to find [log4j2-testc387f44.yml] using context class loader sun.misc.Launcher$AppClassLoader@c387f44.
2016-07-20 09:42:27,719 AWT-EventQueue-0 TRACE Trying to find [log4j2-testc387f44.yml] using sun.misc.Launcher$AppClassLoader@c387f44 class loader.
2016-07-20 09:42:27,720 AWT-EventQueue-0 TRACE Trying to find [log4j2-testc387f44.yml] using sun.misc.Launcher$AppClassLoader@c387f44 class loader.
2016-07-20 09:42:27,721 AWT-EventQueue-0 TRACE Trying to find [log4j2-testc387f44.yml] using ClassLoader.getSystemResource().
2016-07-20 09:42:27,721 AWT-EventQueue-0 TRACE Trying to find [log4j2-testc387f44.yaml] using context class loader sun.misc.Launcher$AppClassLoader@c387f44.
2016-07-20 09:42:27,722 AWT-EventQueue-0 TRACE Trying to find [log4j2-testc387f44.yaml] using sun.misc.Launcher$AppClassLoader@c387f44 class loader.
2016-07-20 09:42:27,722 AWT-EventQueue-0 TRACE Trying to find [log4j2-testc387f44.yaml] using sun.misc.Launcher$AppClassLoader@c387f44 class loader.
2016-07-20 09:42:27,723 AWT-EventQueue-0 TRACE Trying to find [log4j2-testc387f44.yaml] using ClassLoader.getSystemResource().
2016-07-20 09:42:27,723 AWT-EventQueue-0 TRACE Trying to find [log4j2-testc387f44.json] using context class loader sun.misc.Launcher$AppClassLoader@c387f44.
2016-07-20 09:42:27,724 AWT-EventQueue-0 TRACE Trying to find [log4j2-testc387f44.json] using sun.misc.Launcher$AppClassLoader@c387f44 class loader.
2016-07-20 09:42:27,724 AWT-EventQueue-0 TRACE Trying to find [log4j2-testc387f44.json] using sun.misc.Launcher$AppClassLoader@c387f44 class loader.
2016-07-20 09:42:27,724 AWT-EventQueue-0 TRACE Trying to find [log4j2-testc387f44.json] using ClassLoader.getSystemResource().
2016-07-20 09:42:27,725 AWT-EventQueue-0 TRACE Trying to find [log4j2-testc387f44.jsn] using context class loader sun.misc.Launcher$AppClassLoader@c387f44.
2016-07-20 09:42:27,725 AWT-EventQueue-0 TRACE Trying to find [log4j2-testc387f44.jsn] using sun.misc.Launcher$AppClassLoader@c387f44 class loader.
2016-07-20 09:42:27,726 AWT-EventQueue-0 TRACE Trying to find [log4j2-testc387f44.jsn] using sun.misc.Launcher$AppClassLoader@c387f44 class loader.
2016-07-20 09:42:27,726 AWT-EventQueue-0 TRACE Trying to find [log4j2-testc387f44.jsn] using ClassLoader.getSystemResource().
2016-07-20 09:42:27,727 AWT-EventQueue-0 TRACE Trying to find [log4j2-testc387f44.xml] using context class loader sun.misc.Launcher$AppClassLoader@c387f44.
2016-07-20 09:42:27,727 AWT-EventQueue-0 TRACE Trying to find [log4j2-testc387f44.xml] using sun.misc.Launcher$AppClassLoader@c387f44 class loader.
2016-07-20 09:42:27,728 AWT-EventQueue-0 TRACE Trying to find [log4j2-testc387f44.xml] using sun.misc.Launcher$AppClassLoader@c387f44 class loader.
2016-07-20 09:42:27,728 AWT-EventQueue-0 TRACE Trying to find [log4j2-testc387f44.xml] using ClassLoader.getSystemResource().
2016-07-20 09:42:27,728 AWT-EventQueue-0 TRACE Trying to find [log4j2-test.properties] using context class loader sun.misc.Launcher$AppClassLoader@c387f44.
2016-07-20 09:42:27,729 AWT-EventQueue-0 TRACE Trying to find [log4j2-test.properties] using sun.misc.Launcher$AppClassLoader@c387f44 class loader.
2016-07-20 09:42:27,729 AWT-EventQueue-0 TRACE Trying to find [log4j2-test.properties] using sun.misc.Launcher$AppClassLoader@c387f44 class loader.
2016-07-20 09:42:27,730 AWT-EventQueue-0 TRACE Trying to find [log4j2-test.properties] using ClassLoader.getSystemResource().
2016-07-20 09:42:27,730 AWT-EventQueue-0 TRACE Trying to find [log4j2-test.yml] using context class loader sun.misc.Launcher$AppClassLoader@c387f44.
2016-07-20 09:42:27,731 AWT-EventQueue-0 TRACE Trying to find [log4j2-test.yml] using sun.misc.Launcher$AppClassLoader@c387f44 class loader.
2016-07-20 09:42:27,731 AWT-EventQueue-0 TRACE Trying to find [log4j2-test.yml] using sun.misc.Launcher$AppClassLoader@c387f44 class loader.
2016-07-20 09:42:27,732 AWT-EventQueue-0 TRACE Trying to find [log4j2-test.yml] using ClassLoader.getSystemResource().
2016-07-20 09:42:27,732 AWT-EventQueue-0 TRACE Trying to find [log4j2-test.yaml] using context class loader sun.misc.Launcher$AppClassLoader@c387f44.
2016-07-20 09:42:27,732 AWT-EventQueue-0 TRACE Trying to find [log4j2-test.yaml] using sun.misc.Launcher$AppClassLoader@c387f44 class loader.
2016-07-20 09:42:27,733 AWT-EventQueue-0 TRACE Trying to find [log4j2-test.yaml] using sun.misc.Launcher$AppClassLoader@c387f44 class loader.
2016-07-20 09:42:27,733 AWT-EventQueue-0 TRACE Trying to find [log4j2-test.yaml] using ClassLoader.getSystemResource().
2016-07-20 09:42:27,734 AWT-EventQueue-0 TRACE Trying to find [log4j2-test.json] using context class loader sun.misc.Launcher$AppClassLoader@c387f44.
2016-07-20 09:42:27,734 AWT-EventQueue-0 TRACE Trying to find [log4j2-test.json] using sun.misc.Launcher$AppClassLoader@c387f44 class loader.
2016-07-20 09:42:27,735 AWT-EventQueue-0 TRACE Trying to find [log4j2-test.json] using sun.misc.Launcher$AppClassLoader@c387f44 class loader.
2016-07-20 09:42:27,735 AWT-EventQueue-0 TRACE Trying to find [log4j2-test.json] using ClassLoader.getSystemResource().
2016-07-20 09:42:27,735 AWT-EventQueue-0 TRACE Trying to find [log4j2-test.jsn] using context class loader sun.misc.Launcher$AppClassLoader@c387f44.
2016-07-20 09:42:27,736 AWT-EventQueue-0 TRACE Trying to find [log4j2-test.jsn] using sun.misc.Launcher$AppClassLoader@c387f44 class loader.
2016-07-20 09:42:27,736 AWT-EventQueue-0 TRACE Trying to find [log4j2-test.jsn] using sun.misc.Launcher$AppClassLoader@c387f44 class loader.
2016-07-20 09:42:27,737 AWT-EventQueue-0 TRACE Trying to find [log4j2-test.jsn] using ClassLoader.getSystemResource().
2016-07-20 09:42:27,737 AWT-EventQueue-0 TRACE Trying to find [log4j2-test.xml] using context class loader sun.misc.Launcher$AppClassLoader@c387f44.
2016-07-20 09:42:27,737 AWT-EventQueue-0 TRACE Trying to find [log4j2-test.xml] using sun.misc.Launcher$AppClassLoader@c387f44 class loader.
2016-07-20 09:42:27,738 AWT-EventQueue-0 TRACE Trying to find [log4j2-test.xml] using sun.misc.Launcher$AppClassLoader@c387f44 class loader.
2016-07-20 09:42:27,738 AWT-EventQueue-0 TRACE Trying to find [log4j2-test.xml] using ClassLoader.getSystemResource().
2016-07-20 09:42:27,738 AWT-EventQueue-0 TRACE Trying to find [log4j2c387f44.properties] using context class loader sun.misc.Launcher$AppClassLoader@c387f44.
2016-07-20 09:42:27,739 AWT-EventQueue-0 TRACE Trying to find [log4j2c387f44.properties] using sun.misc.Launcher$AppClassLoader@c387f44 class loader.
2016-07-20 09:42:27,739 AWT-EventQueue-0 TRACE Trying to find [log4j2c387f44.properties] using sun.misc.Launcher$AppClassLoader@c387f44 class loader.
2016-07-20 09:42:27,740 AWT-EventQueue-0 TRACE Trying to find [log4j2c387f44.properties] using ClassLoader.getSystemResource().
2016-07-20 09:42:27,740 AWT-EventQueue-0 TRACE Trying to find [log4j2c387f44.yml] using context class loader sun.misc.Launcher$AppClassLoader@c387f44.
2016-07-20 09:42:27,740 AWT-EventQueue-0 TRACE Trying to find [log4j2c387f44.yml] using sun.misc.Launcher$AppClassLoader@c387f44 class loader.
2016-07-20 09:42:27,741 AWT-EventQueue-0 TRACE Trying to find [log4j2c387f44.yml] using sun.misc.Launcher$AppClassLoader@c387f44 class loader.
2016-07-20 09:42:27,741 AWT-EventQueue-0 TRACE Trying to find [log4j2c387f44.yml] using ClassLoader.getSystemResource().
2016-07-20 09:42:27,742 AWT-EventQueue-0 TRACE Trying to find [log4j2c387f44.yaml] using context class loader sun.misc.Launcher$AppClassLoader@c387f44.
2016-07-20 09:42:27,742 AWT-EventQueue-0 TRACE Trying to find [log4j2c387f44.yaml] using sun.misc.Launcher$AppClassLoader@c387f44 class loader.
2016-07-20 09:42:27,742 AWT-EventQueue-0 TRACE Trying to find [log4j2c387f44.yaml] using sun.misc.Launcher$AppClassLoader@c387f44 class loader.
2016-07-20 09:42:27,743 AWT-EventQueue-0 TRACE Trying to find [log4j2c387f44.yaml] using ClassLoader.getSystemResource().
2016-07-20 09:42:27,743 AWT-EventQueue-0 TRACE Trying to find [log4j2c387f44.json] using context class loader sun.misc.Launcher$AppClassLoader@c387f44.
2016-07-20 09:42:27,744 AWT-EventQueue-0 TRACE Trying to find [log4j2c387f44.json] using sun.misc.Launcher$AppClassLoader@c387f44 class loader.
2016-07-20 09:42:27,744 AWT-EventQueue-0 TRACE Trying to find [log4j2c387f44.json] using sun.misc.Launcher$AppClassLoader@c387f44 class loader.
2016-07-20 09:42:27,744 AWT-EventQueue-0 TRACE Trying to find [log4j2c387f44.json] using ClassLoader.getSystemResource().
2016-07-20 09:42:27,745 AWT-EventQueue-0 TRACE Trying to find [log4j2c387f44.jsn] using context class loader sun.misc.Launcher$AppClassLoader@c387f44.
2016-07-20 09:42:27,745 AWT-EventQueue-0 TRACE Trying to find [log4j2c387f44.jsn] using sun.misc.Launcher$AppClassLoader@c387f44 class loader.
2016-07-20 09:42:27,746 AWT-EventQueue-0 TRACE Trying to find [log4j2c387f44.jsn] using sun.misc.Launcher$AppClassLoader@c387f44 class loader.
2016-07-20 09:42:27,746 AWT-EventQueue-0 TRACE Trying to find [log4j2c387f44.jsn] using ClassLoader.getSystemResource().
2016-07-20 09:42:27,746 AWT-EventQueue-0 TRACE Trying to find [log4j2c387f44.xml] using context class loader sun.misc.Launcher$AppClassLoader@c387f44.
2016-07-20 09:42:27,747 AWT-EventQueue-0 TRACE Trying to find [log4j2c387f44.xml] using sun.misc.Launcher$AppClassLoader@c387f44 class loader.
2016-07-20 09:42:27,747 AWT-EventQueue-0 TRACE Trying to find [log4j2c387f44.xml] using sun.misc.Launcher$AppClassLoader@c387f44 class loader.
2016-07-20 09:42:27,747 AWT-EventQueue-0 TRACE Trying to find [log4j2c387f44.xml] using ClassLoader.getSystemResource().
2016-07-20 09:42:27,748 AWT-EventQueue-0 TRACE Trying to find [log4j2.properties] using context class loader sun.misc.Launcher$AppClassLoader@c387f44.
2016-07-20 09:42:27,748 AWT-EventQueue-0 TRACE Trying to find [log4j2.properties] using sun.misc.Launcher$AppClassLoader@c387f44 class loader.
2016-07-20 09:42:27,748 AWT-EventQueue-0 TRACE Trying to find [log4j2.properties] using sun.misc.Launcher$AppClassLoader@c387f44 class loader.
2016-07-20 09:42:27,749 AWT-EventQueue-0 TRACE Trying to find [log4j2.properties] using ClassLoader.getSystemResource().
2016-07-20 09:42:27,749 AWT-EventQueue-0 TRACE Trying to find [log4j2.yml] using context class loader sun.misc.Launcher$AppClassLoader@c387f44.
2016-07-20 09:42:27,750 AWT-EventQueue-0 TRACE Trying to find [log4j2.yml] using sun.misc.Launcher$AppClassLoader@c387f44 class loader.
2016-07-20 09:42:27,750 AWT-EventQueue-0 TRACE Trying to find [log4j2.yml] using sun.misc.Launcher$AppClassLoader@c387f44 class loader.
2016-07-20 09:42:27,750 AWT-EventQueue-0 TRACE Trying to find [log4j2.yml] using ClassLoader.getSystemResource().
2016-07-20 09:42:27,751 AWT-EventQueue-0 TRACE Trying to find [log4j2.yaml] using context class loader sun.misc.Launcher$AppClassLoader@c387f44.
2016-07-20 09:42:27,751 AWT-EventQueue-0 TRACE Trying to find [log4j2.yaml] using sun.misc.Launcher$AppClassLoader@c387f44 class loader.
2016-07-20 09:42:27,751 AWT-EventQueue-0 TRACE Trying to find [log4j2.yaml] using sun.misc.Launcher$AppClassLoader@c387f44 class loader.
2016-07-20 09:42:27,752 AWT-EventQueue-0 TRACE Trying to find [log4j2.yaml] using ClassLoader.getSystemResource().
2016-07-20 09:42:27,752 AWT-EventQueue-0 TRACE Trying to find [log4j2.json] using context class loader sun.misc.Launcher$AppClassLoader@c387f44.
2016-07-20 09:42:27,753 AWT-EventQueue-0 TRACE Trying to find [log4j2.json] using sun.misc.Launcher$AppClassLoader@c387f44 class loader.
2016-07-20 09:42:27,753 AWT-EventQueue-0 TRACE Trying to find [log4j2.json] using sun.misc.Launcher$AppClassLoader@c387f44 class loader.
2016-07-20 09:42:27,753 AWT-EventQueue-0 TRACE Trying to find [log4j2.json] using ClassLoader.getSystemResource().
2016-07-20 09:42:27,754 AWT-EventQueue-0 TRACE Trying to find [log4j2.jsn] using context class loader sun.misc.Launcher$AppClassLoader@c387f44.
2016-07-20 09:42:27,754 AWT-EventQueue-0 TRACE Trying to find [log4j2.jsn] using sun.misc.Launcher$AppClassLoader@c387f44 class loader.

如果您想了解更多详情,请与我们联系。

2 个答案:

答案 0 :(得分:0)

我确定希望看到您的申请。从日志中看起来应用程序已经结束。 AWT-EventQueue-0(新线程?)然后开始运行。记录已关闭,因此它尝试重新初始化但不知道要使用哪种配置。要解决这个问题,应用程序创建的线程需要在主线程结束之前运行。

答案 1 :(得分:0)

傻傻的我:

最初,我写了一个Swing应用程序,通过主线程中的appl.setVisible(true);打开UI。最后,我还添加了LogManager.shutdown();以便在终止后清理资源。

在浏览互联网并通过SO获取有关Swing的更多信息时,代码出现在适当的多线程应用程序中(请参阅SwingUtilities.invokeLater(new Runnable() {...});),同时保持LogManager的关闭挂钩。

<强>修正

由于@rgoers非常好的答案,我看到记录器的名称已从 xyz.my.logger: DEBUG 更改为 xyz.my .logger:<!强>关闭