Java/오류노트

[Java/오류노트] Solved - Could not create plugin of type class org.apache.logging.log4j.core.async.AsyncLoggerConfig for element AsyncLogger: java.lang.NoClassDefFoundError: com/lmax/disruptor/EventFactory java.lang.NoClassDefFoundError: com/lmax/di..

adjh54 2024. 1. 17. 16:34
728x170
해당 글에서는 Log4j2에서 비동기 로깅에 대해 설정하는 과정 중에 발생하는 오류에 대한 해결한 방법에 대해 공유합니다.


 

1) 문제점


💡 문제점

- Log4j2에서 ‘비동기 로깅’과 관련되어 테스트를 하는 중에 아래와 같은 문제가 발생하였습니다.

Could not create plugin of type class org.apache.logging.log4j.core.async.AsyncLoggerConfig for element AsyncLogger: java.lang.NoClassDefFoundError: com/lmax/disruptor/EventFactory java.lang.NoClassDefFoundError: com/lmax/disruptor/EventFactory

- 해당 문제는 AsyncLogger를 사용하는데 com.lmax:disruptor 클래스를 찾을 수 없다는 문제입니다.

 

 

 

 

 

2) 해결방법


💡 해결방법

- 공식사이트 내에서도 Log4j2에서 비동기 로깅을 사용하려면 ‘LMAX Disruptor’를 사용하라는 권장을 하고 있습니다.
- 그렇기에 이를 설치하여 해결합니다.

 

https://logging.apache.org/log4j/2.x/manual/async.html#under-the-hood

 

 

 

💡 최신버전으로는 4.0.0 버전이 나왔지만 개인적으로 수행이 안되는 문제가 있어서 3.6.6 버전을 통해 설치를 하고 아래와 같이 해결하였습니다. (참고로 프로젝트 환경은 Java 17입니다.)
// <https://mvnrepository.com/artifact/com.lmax/disruptor>
implementation 'com.lmax:disruptor:4.0.0'

# or

// <https://mvnrepository.com/artifact/com.lmax/disruptor>
implementation 'com.lmax:disruptor:3.6.6'

Maven Repository: com.lmax » disruptor

 

 

💡 수행이 잘 됨을 확인하였습니다.

 

 

 

 

💡 [참고] 이와 관련된 log4j2의 비동기 설정에 대해 궁금하시면 아래의 링크를 참고하시면 도움이 됩니다.
 

[Java] Spring Boot Log4j2 이해하기 -2 : 비동기 로깅(Asynchronous Loggers)

해당 글에서는 Spring Boot 환경에서 Log4j2를 이용하여 비동기 로깅에 대해 이해하고 사용하는 방법에 대해 알아봅니다. 💡 [참고] Log4j2에 대해 상세하게 궁금하시거나 동기식 로깅을 원하시면 아

adjh54.tistory.com

 

 

 

 

오늘도 감사합니다. 😀

그리드형