- 背景: log4j2日志接入, 使用AsyncLogger + (sync)Appender的方式
- 问题:
ERROR Could not create plugin of type class org.apache.logging.log4j.core.async.AsyncLoggerConfig for element AsyncLogger: java.lang.NoClassDefFoundError: com/lmax/disruptor/EventHandler
- 解决思路:
log4j2采用AsyncLogger的错误,配置文件,配置日志打印控制
pom文件中,或者说项目的依赖jar包中,只引入了log4j2的相关api包和core包。
补充一个 额外的log4j2本身代码逻辑所依赖的 disruptor包。
log4j2的AsyncLogger本身的逻辑采用了缓冲区思想,使用的是disruptor框架来实现一个环形无锁队列。
<!-- ERROR Could not create plugin of type class org.apache.logging.log4j.core.async.AsyncLoggerConfig for element AsyncLogger: java.lang.NoClassDefFoundError: com/lmax/disruptor/EventHandler -->
<dependency>
<groupId>com.lmax</groupId>
<artifactId>disruptor</artifactId>
<version>3.3.6</version>
</dependency>
<!-- log4j2日志End -->
- 1
- 2
- 3
- 4
- 5
- 6
- 7