title: How can I remove logback from a library's dependency while keeping SLF4J?
body: <p>In my Vaadin project, I have a dependency on a certain library. This library uses slf4j for logging. In the library pom, logback slf4j binding is added as a runtime dependency.</p>
  
  <pre><code>    &lt;dependency&gt;
          &lt;groupId&gt;ch.qos.logback&lt;/groupId&gt;
          &lt;artifactId&gt;logback-classic&lt;/artifactId&gt;
          &lt;version&gt;${logback.version}&lt;/version&gt;
          &lt;scope&gt;runtime&lt;/scope&gt;
      &lt;/dependency&gt;
  </code></pre>
  
  <p>In my application, I directly use log4j for logging. I want the logs added by the library to go in my log4j log.</p>
  
  <p>For this, I added following to my pom to include slf4j log4j binding</p>
  
  <pre><code>    &lt;dependency&gt;
          &lt;groupId&gt;org.slf4j&lt;/groupId&gt;
          &lt;artifactId&gt;slf4j-log4j12&lt;/artifactId&gt;
          &lt;version&gt;1.7.12&lt;/version&gt;
      &lt;/dependency&gt;
  </code></pre>
  
  <p>However, slf4j complains that it has found multiple bindings.</p>
  
  <pre><code>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]
  </code></pre>
  
  <p>I checked the dependency tree of my application, which has following for its dependency on logback. (Following is the only dependency on logback)</p>
  
  <pre><code>[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
  </code></pre>
  
  <p>Also, when I checked inside <code>WEB-INF\lib</code> directory in my war file, I found following jars.</p>
  
  <pre><code>logback-access-1.0.13.jar
  logback-classic-1.0.13.jar
  logback-core-1.0.13.jar
  </code></pre>
  
  <p>Why did logback ended up in my lib directory? As I have heard, runtime dependencies should not come into libs directory.</p>
  
  <p>How should I resolve this? The library is developed within my company and I can ask the library developers to remove the logback runtime dependencies if needed.</p>