title: SLF4j resolve multiple bindings
body: <p>In my application, I'm using SLF4j as logging facade with multiple bindings present as</p>
  
  <ol>
  <li>slf4j-simple-1.6.2.jar </li>
  <li>logback-classic-1.0.4.jar</li>
  </ol>
  
  <p>Both of these are defined in pom.xml as</p>
  
  <pre><code>    **&lt;!--MANDATORY --&gt;**
      &lt;dependency&gt;
          &lt;groupId&gt;org.slf4j&lt;/groupId&gt;
          &lt;artifactId&gt;slf4j-api&lt;/artifactId&gt;
          &lt;version&gt;1.6.2&lt;/version&gt;
      &lt;/dependency&gt;
  
      **&lt;!--SIMPLY DUMPS THE MESSAGE TO ERROR STREAM --&gt;**
      &lt;dependency&gt;
          &lt;groupId&gt;org.slf4j&lt;/groupId&gt;
          &lt;artifactId&gt;slf4j-simple&lt;/artifactId&gt;
          &lt;version&gt;1.6.2&lt;/version&gt;
      &lt;/dependency&gt;
  
      **&lt;!--logback : further configuration in logback.xml --&gt;**
      &lt;dependency&gt;
          &lt;groupId&gt;ch.qos.logback&lt;/groupId&gt;
          &lt;artifactId&gt;logback-core&lt;/artifactId&gt;
          &lt;version&gt;1.0.4&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;ch.qos.logback&lt;/groupId&gt;
          &lt;artifactId&gt;logback-classic&lt;/artifactId&gt;
          &lt;version&gt;1.0.4&lt;/version&gt;
      &lt;/dependency&gt; 
  </code></pre>
  
  <p>A simple test program, which can be run natively</p>
  
  <pre><code>import org.slf4j.Logger;
  import org.slf4j.LoggerFactory;
  
  public class TimePass {
      private Logger log = LoggerFactory.getLogger(getClass());
      public static void main(String[] args) {
          new TimePass().run();
      }
  
      private void run() {
          System.out.println(log);
          log.info("WE ARE RUNNING");
          System.out.println("HIHIHIHI");
      }
  
  }
  </code></pre>
  
  <p>This project/webapp is deployed on 2 locations.
  But when I run it on both, the results are strikingly different.</p>
  
  <pre><code>On 1 instance, output is
  
      SLF4J: Class path contains multiple SLF4J bindings.
      SLF4J: Found binding in [jar:file:/home/hemant/.m2/repository/org/slf4j/slf4j-simple/1.6.2/slf4j-simple-1.6.2.jar!/org/slf4j/impl/StaticLoggerBinder.class]
      SLF4J: Found binding in [jar:file:/home/hemant/.m2/repository/ch/qos/logback/logback-classic/1.0.4/logback-classic-1.0.4.jar!/org/slf4j/impl/StaticLoggerBinder.class]
      SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
      0 [main] INFO com.expertly.bin.TimePass - WE ARE RUNNING
      org.slf4j.impl.SimpleLogger(com.expertly.bin.TimePass)
      HIHIHIHI
  </code></pre>
  
  <p>While on the other, its</p>
  
  <pre><code>SLF4J: Class path contains multiple SLF4J bindings.
  SLF4J: Found binding in [jar:file:/home/hemant/.m2/repository/ch/qos/logback/logback-classic/1.0.4/logback-classic-1.0.4.jar!/org/slf4j/impl/StaticLoggerBinder.class]
  SLF4J: Found binding in [jar:file:/home/hemant/.m2/repository/org/slf4j/slf4j-simple/1.6.2/slf4j-simple-1.6.2.jar!/org/slf4j/impl/StaticLoggerBinder.class]
  SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
  14:58:18,760 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Could NOT find resource [logback.groovy]
  14:58:18,760 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Could NOT find resource [logback-test.xml]
  14:58:18,760 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Found resource [logback.xml] at [file:/home/hemant/Project/Expertly/ee/workspace/branches/integration/target/ROOT/WEB-INF/classes/logback.xml]
  14:58:18,823 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - debug attribute not set
  14:58:18,827 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.classic.sift.SiftingAppender]
  14:58:18,831 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [SIFT]
  14:58:18,853 |-INFO in ch.qos.logback.core.joran.action.NestedComplexPropertyIA - Assuming default type [ch.qos.logback.classic.sift.MDCBasedDiscriminator] for [discriminator] property
  14:58:18,859 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.rolling.RollingFileAppender]
  14:58:18,862 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [FILE-HIBERNATE]
  14:58:18,868 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@59:13 - no applicable action for [Encoding], current pattern is [[configuration][appender][Encoding]]
  14:58:18,897 |-WARN in ch.qos.logback.core.rolling.RollingFileAppender[FILE-HIBERNATE] - This appender no longer admits a layout as a sub-component, set an encoder instead.
  14:58:18,897 |-WARN in ch.qos.logback.core.rolling.RollingFileAppender[FILE-HIBERNATE] - To ensure compatibility, wrapping your layout in LayoutWrappingEncoder.
  14:58:18,897 |-WARN in ch.qos.logback.core.rolling.RollingFileAppender[FILE-HIBERNATE] - See also http://logback.qos.ch/codes.html#layoutInsteadOfEncoder for details
  14:58:18,905 |-INFO in ch.qos.logback.core.rolling.FixedWindowRollingPolicy@1fc6e42 - Will use zip compression
  14:58:18,910 |-INFO in ch.qos.logback.core.rolling.RollingFileAppender[FILE-HIBERNATE] - Active log file name: catalina.base_IS_UNDEFINED/logs/hibernate.log
  14:58:18,910 |-INFO in ch.qos.logback.core.rolling.RollingFileAppender[FILE-HIBERNATE] - File property is set to [catalina.base_IS_UNDEFINED/logs/hibernate.log]
  14:58:18,911 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.classic.net.SMTPAppender]
  14:58:18,918 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [EMAIL]
  14:58:18,937 |-INFO in ch.qos.logback.classic.joran.action.RootLoggerAction - Setting level of ROOT logger to ERROR
  14:58:18,937 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [EMAIL] to Logger[ROOT]
  14:58:18,937 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [org.hibernate.type] to INFO
  14:58:18,937 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting additivity of logger [org.hibernate.type] to false
  14:58:18,937 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [FILE-HIBERNATE] to Logger[org.hibernate.type]
  14:58:18,937 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [org.hibernate] to INFO
  14:58:18,938 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting additivity of logger [org.hibernate] to false
  14:58:18,938 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [FILE-HIBERNATE] to Logger[org.hibernate]
  14:58:18,938 |-INFO in ch.qos.logback.classic.joran.action.RootLoggerAction - Setting level of ROOT logger to DEBUG
  14:58:18,938 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [SIFT] to Logger[ROOT]
  14:58:18,938 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - End of configuration.
  14:58:18,939 |-INFO in ch.qos.logback.classic.joran.JoranConfigurator@1aaf0b3 - Registering current configuration as safe fallback point
  
  Logger[com.expertly.bin.TimePass]
  HIHIHIHI
  </code></pre>
  
  <p>The issue seems to be in both the cases, multiple bindings were enlisted but in different order.</p>
  
  <p>**In Case 1 : where it logged :
   1. slf4j-simple-1.6.2.jar 
   2. logback-classic-1.0.4.jar
   And it used first binding to log</p>
  
  <p>In Case 2 : where it didnt log, the order was opposite and hence it went for looking for logback.xml and couldn't resolve the webcontainer specific variables (${catalina.home})**</p>
  
  <p>I don't know the reason for this reversal.</p>
  
  <p>I need both the bindings. Just in case when I run a java file natively, I want slf4j-simple binding to preceed the logback binding.</p>
  
  <p>Thanks in advance.</p>