In my Vaadin project, I have a dependency on a specific library. This library uses slf4j for logging. In the pom library, the logback slf4j binding is added as a run-time dependency.
<dependency> <groupId>ch.qos.logback</groupId> <artifactId>logback-classic</artifactId> <version>${logback.version}</version> <scope>runtime</scope> </dependency>
In my application, I use log4j directly for logging. I want the logs added by the library to log log4j.
For this, I added the following to my pom to enable slf4j log4j binding
<dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-log4j12</artifactId> <version>1.7.12</version> </dependency>
However, slf4j complains that it has detected several bindings.
SLF4J: Class path contains multiple SLF4J bindings. SLF4J: Found binding in [jar:file:/D:/program_files/apache-tomcat-8.0.24/temp/0-ROOT/WEB-INF/lib/logback-classic-1.0.13.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: Found binding in [jar:file:/D:/program_files/apache-tomcat-8.0.24/temp/0-ROOT/WEB-INF/lib/slf4j-log4j12-1.7.12.jar!/org/slf4j/impl/StaticLoggerBinder.class]
I checked the dependency tree of my application, which has the following values ββfor its dependency on logback. (The following is the only logback dependency)
[INFO] | +- com.mycompany.mylib:libname:jar:1.1.0-SNAPSHOT:compile [INFO] | | +- org.slf4j:jcl-over-slf4j:jar:1.7.5:runtime [INFO] | | +- ch.qos.logback:logback-classic:jar:1.0.13:runtime [INFO] | | | \- ch.qos.logback:logback-core:jar:1.0.13:runtime [INFO] | | +- ch.qos.logback:logback-access:jar:1.0.13:runtime
In addition, when I checked inside the WEB-INF\lib directory in my war file, I found the following banks.
logback-access-1.0.13.jar logback-classic-1.0.13.jar logback-core-1.0.13.jar
Why did the registry end in my lib directory? As I heard, runtime dependencies should not go into the libs directory.
How do I resolve this? The library was developed in my company, and I can ask the library developers to remove the necessary log runtime dependencies.