title: org.slf4j.helpers.SubstituteLogger cannot be cast to ch.qos.logback.classic.Logger
body: <p>I've seen some questions very similar to this one (<a href="https://stackoverflow.com/questions/15483309/org-slf4j-helpers-noploggerfactory-cannot-be-cast-to-ch-qos-logback-classic-logg">like this one</a>), but none of them received a good answer, or at least one that explained or solved this problem</p>
  
  <p>I was able to create a very small project (basically 2 Scala classes - each with a logger - and 2 test classes) with a similar structure to my real project where I found the problem. The example is available here: <a href="https://bitbucket.org/pedrorijo91/logger-exp" rel="noreferrer">project example</a></p>
  
  <p>The problem happens when I run <code>sbt test</code>, resulting in the following error:</p>
  
  <pre><code>{14:43:41} (#47) ~/Desktop/logger-exp/log-exp@pedrorijo(master) $ sbt test
  Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=384m; support was removed in 8.0
  [info] Loading global plugins from /Users/pedrorijo/.sbt/0.13/plugins
  [info] Loading project definition from /Users/pedrorijo/Desktop/git/scala/logger-exp/log-exp/project
  [info] Set current project to log-exp (in build file:/Users/pedrorijo/Desktop/git/scala/logger-exp/log-exp/)
  [info] HelloTest:
  [info] Exception encountered when attempting to run a suite with class name: HelloTest *** ABORTED ***
  [info]   java.lang.ExceptionInInitializerError:
  [info]   at HelloTest$$anonfun$1.apply$mcV$sp(HelloTest.scala:8)
  [info]   at HelloTest$$anonfun$1.apply(HelloTest.scala:8)
  [info]   at HelloTest$$anonfun$1.apply(HelloTest.scala:8)
  [info]   at org.scalatest.Transformer$$anonfun$apply$1.apply$mcV$sp(Transformer.scala:22)
  [info]   at org.scalatest.OutcomeOf$class.outcomeOf(OutcomeOf.scala:85)
  [info]   at org.scalatest.OutcomeOf$.outcomeOf(OutcomeOf.scala:104)
  [info]   at org.scalatest.Transformer.apply(Transformer.scala:22)
  [info]   at org.scalatest.Transformer.apply(Transformer.scala:20)
  [info]   at org.scalatest.FunSuiteLike$$anon$1.apply(FunSuiteLike.scala:166)
  [info]   at org.scalatest.Suite$class.withFixture(Suite.scala:1122)
  [info]   ...
  [info]   Cause: java.lang.ClassCastException: org.slf4j.helpers.SubstituteLogger cannot be cast to ch.qos.logback.classic.Logger
  [info]   at com.example.Hello$.&lt;init&gt;(Hello.scala:8)
  [info]   at com.example.Hello$.&lt;clinit&gt;(Hello.scala)
  [info]   at HelloTest$$anonfun$1.apply$mcV$sp(HelloTest.scala:8)
  [info]   at HelloTest$$anonfun$1.apply(HelloTest.scala:8)
  [info]   at HelloTest$$anonfun$1.apply(HelloTest.scala:8)
  [info]   at org.scalatest.Transformer$$anonfun$apply$1.apply$mcV$sp(Transformer.scala:22)
  [info]   at org.scalatest.OutcomeOf$class.outcomeOf(OutcomeOf.scala:85)
  [info]   at org.scalatest.OutcomeOf$.outcomeOf(OutcomeOf.scala:104)
  [info]   at org.scalatest.Transformer.apply(Transformer.scala:22)
  [info]   at org.scalatest.Transformer.apply(Transformer.scala:20)
  [info]   ...
  SLF4J: The following set of substitute loggers may have been accessed
  SLF4J: during the initialization phase. Logging calls during this
  SLF4J: phase were not honored. However, subsequent logging calls to these
  SLF4J: loggers will work as normally expected.
  SLF4J: See also http://www.slf4j.org/codes.html#substituteLogger
  SLF4J: com.example.Hello$
  14:43:52.846 [pool-6-thread-4-ScalaTest-running-WorldTest] INFO  com.example.World$ - LOGGING
  [info] WorldTest:
  [info] - test
  [info] Run completed in 456 milliseconds.
  [info] Total number of tests run: 1
  [info] Suites: completed 1, aborted 1
  [info] Tests: succeeded 1, failed 0, canceled 0, ignored 0, pending 0
  [info] *** 1 SUITE ABORTED ***
  [error] Error during tests:
  [error]     HelloTest
  [error] (test:test) sbt.TestsFailedException: Tests unsuccessful
  [error] Total time: 1 s, completed Aug 2, 2015 2:43:52 PM
  </code></pre>
  
  <p>but if I run each of the tests individually through:</p>
  
  <p><code>sbt "testOnly HelloTest"</code> and <code>sbt "testOnly WorlTest"</code> I get no error.</p>
  
  <p>As far as I've seen this is not just a Scala issue, it seems that in Java is also possible to happen. Furthermore, I've read that during initialization the loggers are substituted by a  <a href="http://www.slf4j.org/codes.html#substituteLogger" rel="noreferrer">Substitute Logger</a>.</p>
  
  <p>But I can't understand:</p>
  
  <ol>
  <li>why it only happens in tests, and when running both tests? </li>
  <li>why it happens?</li>
  <li>how to debug/solve this problem?</li>
  </ol>
  
  <blockquote>
    <p>As I said before, I've created a repository with a working example (working, meaning with the error happening) here: <a href="https://bitbucket.org/pedrorijo91/logger-exp" rel="noreferrer">project example</a></p>
  </blockquote>