Reputation: 4514
I wanted to update my slf4j-api dependencies to 1.8.0-beta2, but with this version I am no longer able to use uk.org.lidalia:slf4j-test:1.2.0 for testing logging, because of the following error:
SLF4J: Class path contains SLF4J bindings targeting slf4j-api versions prior to 1.8.
SLF4J: Ignoring binding found at [jar:file:/C:/Users/OEM/.m2/repository/uk/org/lidalia/slf4j-test/1.2.0/slf4j-test-1.2.0.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#ignoredBindings for an explanation.
I found in the documentation this is because:
Planning for the advent of Jigsaw (Java 9), slf4j-api version 1.8.x and later use the ServiceLoader mechanism. Earlier versions of SLF4J relied on the static binder mechanism which is no longer honored by slf4j-api.
In case SLF4J finds no providers targeting SLF4J 1.8 but finds instead bindings targeting SLF4J 1.7 or earlier, it will list the bindings it finds but otherwise ignores them.
What optionsdo I have for slf4j logging testing? uk.org.lidalia:slf4j-test:1.2.0 is the latest version and has not been updated since 2015.
Upvotes: 2
Views: 2223
Reputation: 11
Maybe one way is to set logback-classic as a dependency with a 'test' scope (here using Maven):
<!-- Logging during tests -->
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<scope>test</scope>
<version>LATEST</version>
</dependency>
and test logging according to instructions in this other post: https://stackoverflow.com/a/29077499/10881066
Also, have you seen spf4j-slf4j-test? This looks like what you are looking for. The latest version does not yet support slf4j 1.8 but the project seems to be actively maintained.
Support for Slf4j 1.8 may be added in a near future?
Upvotes: 1