我最近将我的应用程序升级为使用log4j2。我正在尝试利用其异步记录器功能。但是,看起来它不是在创建一个。根据Log4j Async config,它说,
要使所有记录器异步,请将干扰器jar添加到类路径,并将系统属性Log4jContextSelector设置为org.apache.logging.log4j.core.async.AsyncLoggerContextSelector。我还在log4j.xml中设置status =“ trace”,以查看它是否配置并实例化了异步记录器。但是看起来好像失败了。
2017-01-25 01:58:30,799主要TRACE重新注册上下文(1/1):'AsyncContext @ 18b4aac2'org.apache.logging.log4j.core.async.AsyncLoggerContext@6bf08014 2017-01-25 01:58:30,800主TRACE正在注销,但未找到与'org.apache.logging.log4j2:type = AsyncContext @ 18b4aac2'相匹配的MBean,2017-01-25 01:58:30,800主TRACE正在注销,但未找到与'org.apache.logging.log4j2相匹配的MBean: type = AsyncContext @ 18b4aac2,component = StatusLogger'2017-01-25 01:58:30,800主TRACE正在注销,但未找到与'org.apache.logging.log4j2匹配的MBean:type = AsyncContext @ 18b4aac2,component = ContextSelector'2017-01 -25 01:58:30,801主要TRACE正在注销,但未找到与'org.apache.logging.log4j2相匹配的MBean:type = AsyncContext @ 18b4aac2,component = Loggers,name ='2017-01-25 01:58:30,801主TRACE正在注销,但未找到与'org.apache.logging.log4j2:type = AsyncContext @ 18b4aac2,component = Appenders,name = ' 匹配的MBean: '2017-01-25 01:58: 30,801个主要的TRACE注销,但未找到匹配'org.apache.logging.log4j2:type = AsyncContext @ 18b4aac2,component = AsyncAppenders,name = '2017-01-25 01:58:30,801个主要的TRACE正在注销,但未找到匹配的MBean org.apache.logging.log4j2:type = AsyncContext @ 18b4aac2,component = AsyncLoggerRingBuffer'2017-01-25 01:58:30,802主要TRACE正在注销,但未找到与'org.apache.logging.log4j2:type = AsyncContext @ 18b4aac2匹配的MBean ,component =记录器,名称=,subtype = RingBuffer'2017-01-25 01:58:30,803主DEBUG注册MBean org.apache.logging.log4j2:type = AsyncContext @ 18b4aac2 2017-01-25 01:58:30,805主DEBUG注册MBean org.apache。 logging.log4j2:type = AsyncContext @ 18b4aac2,component = AsyncLoggerRingBuffer 2017年1月25日01:58:30,806主要调试已注册MBean org.apache.logging.log4j2:type = AsyncContext @ 18b4aac2,component = StatusLogger 2017-01-25 01 :58:30,807主调试器注册MBean org.apache.logging.log4j2:type = AsyncContext @ 18b4aac2,component = ContextSelector 2017-01-25 01:58:30,816 main跟踪使用默认SystemClock作为时间戳记。2017-01-25 01:58:30,816主要TRACE使用DummyNanoClock进行纳秒级时间戳记。2017年1月25日01:58:30,817主调试已完成对URI /etc/opt/sun/im/default/config/log4j2.xml中的context [name = AsyncContext @ 18b4aac2]的重新配置。apache.logging.log4j.core.async.AsyncLoggerContext@6bf08014)和可选的ClassLoader:null 2017-01-25 01:58:30,817 main DEBUG Shutdown hook已启用。注册一个新的。2017年1月25日01:58:30,818主调试LoggerContext [name = AsyncContext @ 18b4aac2,org.apache.logging.log4j.core.async.AsyncLoggerContext@6bf08014]开始正常。
因为我看不到“启动AsyncLogger破坏者”之类的东西。
然后按照建议,我尝试使用asyncLogger标记,可以看到它正在打印,
2017-01-25 00:27:26,970主TRACE AsyncLoggerConfigDisruptor为此配置创建新的中断器。2017年1月25日00:27:26,971主要TRACE属性AsyncLoggerConfig.WaitStrategy = TIMEOUT 2017年1月25日00:27:26,987主要DEBUG使用ringbufferSize = 4096,waitStrategy = TimeoutBlockingWaitStrategy,exceptionHandler = org.apache为此配置启动AsyncLoggerConfig中断程序.logging.log4j.core.async.AsyncLoggerConfigDefaultExceptionHandler @ 7f284218 ... 2017-01-25 00:27:26,988主要TRACE AsyncLoggerConfig [xmppd]正在启动...
但是在稍后的阶段,它再次为找不到的类抛出异常,
2017-01-25 00:27:31,658主要错误无法为元素AsyncLogger调用类org.apache.logging.log4j.core.async.AsyncLoggerConfig类中的工厂方法。java.lang.reflect.InvocationTargetException at sun.reflect.NativeMethodAccessorImpl.invoke0(本地方法)at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) org.apache.logging处的org.apache.logging.log4j.core.config.plugins.util.PluginBuilder.build(PluginBuilder.java:132)处的java.lang.reflect.Method.invoke(Method.java:498)位于org.apache.logging.log4j.core.config.AbstractConfiguration的log4j.core.config.AbstractConfiguration.createPluginObject(AbstractConfiguration.java:942)。
我已经验证过,我随附的干扰罐具有此类。我正在使用Disruptor-3.3.6.jar。
另外,如何验证异步记录器已启动?
任何帮助,将不胜感激。