오류/Spring

log4jdbc-log4j2 적용중 오류

빨대도둑 2024. 3. 11. 09:51

발생 상황

Log4j2 라이브러리를 찾을 수 없다고 했다. 

하지만 맨 처음 환경 세팅할 때 완벽하게 했지만, 소스는 정직하기 때문에 한번 더 확인해 봤다. 

java.lang.IllegalStateException: Failed to load ApplicationContext
.....
.....
Caused by: org.springframework.beans.factory.BeanCreationException: 
Error creating bean with name 'hikariConfig' defined in URL 
[file:src/main/webapp/WEB-INF/root-context.xml]: Error setting property values; 
nested exception is org.springframework.beans.PropertyBatchUpdateException; 
nested PropertyAccessExceptions (1) are:

PropertyAccessException 1: org.springframework.beans.MethodInvocationException: 
Property 'driverClassName' threw exception; 
nested exception is java.lang.NoClassDefFoundError: 
Unable to find Log4j2 as default logging library. 
Please provide a logging library and configure a valid spyLogDelegator name 
in the properties file.

 

해결 방식

maven에 Log4j-api 와 Log4j-core 메이븐을 추가해 주었다.

<dependency>
    <groupId>org.apache.logging.log4j</groupId>
    <artifactId>log4j-api</artifactId>
    <version>2.0.1</version>
</dependency>

<dependency>
    <groupId>org.apache.logging.log4j</groupId>
    <artifactId>log4j-core</artifactId>
    <version>2.0.1</version>
</dependency>

 

참고 블로그

https://jwj1699.tistory.com/14

 

log4jdbc-log4j2 적용중 오류

log4jdbc-log4j2 메이븐추가도했고 log4jdbc-log4j2.properties도 만들어주고 driverClassName과 url도 변경해주었는데 오류가난다... 로그는 다음과 같다java.lang.IllegalStateException: Failed to load ApplicationContext at org.sp

jwj1699.tistory.com