본문 바로가기
SW개발/개발환경

SLF4J 로그가 갑자기 출력되지 않는다.

by 꾸기작 2025. 3. 11.
반응형

운영중인 서비스에서 확인할 사항이 있어 로그파일을 열어보았다.

이런, 처음 시동시에 잠깐 로그가 출력되고 실제 기동중 로그가 없다.

 

로그가 사라지기 전에 이런 로그가 찍힌다.

 

SLF4J(W): No SLF4J providers were found.
SLF4J(W): Defaulting to no-operation (NOP) logger implementation
SLF4J(W): See https://www.slf4j.org/codes.html#noProviders for further details.
SLF4J(W): Class path contains SLF4J bindings targeting slf4j-api versions 1.7.x or earlier.
SLF4J(W): Ignoring binding found at [jar:file:/XXX/mailhoy-app-mail-sender/lib/logback-classic-1.2.3.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J(W): See https://www.slf4j.org/codes.html#ignoredBindings for an explanation.

 

구글링과 ChatGPT, Claude를 통해 여러가지로 알아보니 아래 라인이 핵심일 것으로 보여졌다.

SLF4J(W): Class path contains SLF4J bindings targeting slf4j-api versions 1.7.x or earlier.

 

Gradle dependencies를 통해 라이브러리 모양을 출력해보니 아래와 같은 구간이 있었다.

runtimeClasspath - Runtime classpath of source set 'main'.
+--- org.projectlombok:lombok:1.18.30
+--- javax.annotation:javax.annotation-api:1.3.2
+--- javax.persistence:persistence-api:1.0.2
+--- javax.xml.bind:jaxb-api:2.3.1
|    \--- javax.activation:javax.activation-api:1.2.0
+--- ch.qos.logback:logback-classic:1.2.3
|    +--- ch.qos.logback:logback-core:1.2.3
|    \--- org.slf4j:slf4j-api:1.7.25 -> 2.0.16
...

 

logback-classic:1.2.3버전에 지정된 slf4j-api:1.7.25 버전이 runtime시점에 2.0.16으로 바뀌어져 적용된다.

org.slf4j:slf4j-api:1.7.25 -> 2.0.16

 

그런데, 이게 무슨 문제냐...

버전이 2.x로 바뀌면서 바이너리 호환성이 없다.

동일한 클래스, 메쏘드 구조인데 구현체 자체가 다른 부분들이 많다. > 하위 호환에 문제가 있을 수 있다.

로그 설정 포맷도 지원 폭이 넓어지기는 했지만 이번과 같이 로깅을 하지 못 하는 상항이 발생할 수 있다.

반응형

이를 회피하기 위해 아래 구문을 "build.gradle"파일에 적용했다.

configurations.configureEach {
	resolutionStrategy {
		force 'org.slf4j:slf4j-api:1.7.36'
		eachDependency { DependencyResolveDetails details ->
			if (details.requested.group == 'org.slf4j') {
				details.useVersion '1.7.36'
			}
		}
	}
}

 

이후 Build를 다시 진행하고 문제 해결.

 

Gradle dependencies를 잘 활용해보자.

 

반응형