tonivade / claudb

ClauDB is a REDIS implementation in Java
MIT License
173 stars 32 forks source link

Remove logback, replace with slf4j-api #107

Closed codemonstur closed 3 years ago

codemonstur commented 3 years ago

When using claudb for tests I get an SLF4J error complaining about multiple bindings on the classpath:

SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/C:/Users/me/.m2/repository/org/slf4j/slf4j-nop/1.7.30/slf4j-nop-1.7.30.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/C:/Users/me/.m2/repository/ch/qos/logback/logback-classic/1.2.3/logback-classic-1.2.3.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.

mvn dependency:tree tells me that claudb depends on resp-server which depends on logback.

[INFO] \- com.github.tonivade:claudb:jar:1.7.1:compile
[INFO]    +- com.github.tonivade:resp-server:jar:0.16.0:compile
[INFO]    |  +- io.netty:netty-all:jar:4.1.47.Final:compile
[INFO]    |  +- io.reactivex.rxjava3:rxjava:jar:3.0.0:compile
[INFO]    |  +- com.github.tonivade:purefun-core:jar:1.8:compile
[INFO]    |  |  \- com.github.tonivade:purefun-annotation:jar:1.8:compile
[INFO]    |  \- ch.qos.logback:logback-classic:jar:1.2.3:runtime
[INFO]    |     \- ch.qos.logback:logback-core:jar:1.2.3:runtime

Can logback be replaced with slf4j-api?

tonivade commented 3 years ago

I don't see this warning in claudb. In fact, If I remove logback, then I have this other warning:

SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.

So I need logback as dependency. And I already have slf4j-api as dependency.

compileClasspath - Compile classpath for source set 'main'.
+--- com.github.tonivade:resp-server:0.17.0-SNAPSHOT
|    +--- io.netty:netty-all:4.1.60.Final
|    +--- io.reactivex.rxjava3:rxjava:3.0.11
|    |    \--- org.reactivestreams:reactive-streams:1.0.3
|    +--- com.github.tonivade:purefun-core:2.2
|    |    \--- com.github.tonivade:purefun-annotation:2.2
|    \--- org.slf4j:slf4j-api:1.7.30                    <-- here
+--- net.sf.jopt-simple:jopt-simple:5.0.4
+--- org.luaj:luaj-jse:3.0.1
\--- org.caffinitas.ohc:ohc-core-j8:0.6.1
     \--- org.caffinitas.ohc:ohc-core:0.6.1
          +--- org.slf4j:slf4j-api:1.7.12 -> 1.7.30
          +--- com.google.guava:guava:18.0
          \--- net.java.dev.jna:jna:4.1.0

In any case, I'm going to remove logback from resp-server (because is a pure library) and include it as runtime in claudb.

And finally, you can safely exclude logback from your pom file.

codemonstur commented 3 years ago

I had already removed it using an exclude which solved the issue for me. I just thought I should mention it because it's prettier to not have to exclude it. Thanks for fixing it.