title: Using SLF with Java9 modules
body: <p>I set up a small <a href="https://github.com/michas2/slfTest" rel="noreferrer">test project</a> using java 9 modules. The structure looks like this:</p>
  
  <pre><code>.
  ├── build.gradle
  └── src
      ├── main
      │   └── java
      │       ├── module-info.java
      │       └── slfTest
      │           └── Main.java
      └── test
          └── java
              └── slfTest
                  └── MainTest.java
  </code></pre>
  
  <p>(Feel free to clone and have a look yourself: <code>git clone https://github.com/michas2/slfTest.git</code>)</p>
  
  <p>The classes Main and Main Test only log some simple output:</p>
  
  <pre><code>    Logger logger = LoggerFactory.getLogger(Main.class);
      logger.info("Hello World");
  </code></pre>
  
  <p>Now <code>gradle run</code> works as expected, but <code>gradle test</code> gives a ClassCastException.</p>
  
  <pre><code>    $ gradle run -q
      [main] INFO slfTest.Main - Hello World
      $ gradle test -q
      java.lang.ClassCastException: org.slf4j.simple/org.slf4j.simple.SimpleLoggerFactory cannot be cast to org.gradle.internal.logging.slf4j.OutputEventListenerBackedLoggerContext
              at org.gradle.internal.logging.slf4j.Slf4jLoggingConfigurer.configure(Slf4jLoggingConfigurer.java:42)
              at org.gradle.internal.logging.config.LoggingSystemAdapter.startCapture(LoggingSystemAdapter.java:54)
              at org.gradle.internal.logging.services.DefaultLoggingManager$StartableLoggingSystem.start(DefaultLoggingManager.java:297)
              at org.gradle.internal.logging.services.DefaultLoggingManager.start(DefaultLoggingManager.java:73)
              at org.gradle.internal.logging.services.DefaultLoggingManager.start(DefaultLoggingManager.java:37)
              at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:83)
              at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:64)
              at worker.org.gradle.process.internal.worker.GradleWorkerMain.run(GradleWorkerMain.java:62)
              at worker.org.gradle.process.internal.worker.GradleWorkerMain.main(GradleWorkerMain.java:67)
  </code></pre>
  
  <p>Removing the java 9 module makes things work again. Therefore I assume there is module access problem. - What is the right way to fix it?</p>
  
  <hr>
  
  <p>The content of <code>module-info.java</code> is:</p>
  
  <pre><code>module slfTest {
      requires  org.slf4j;
      exports slfTest;
  }
  </code></pre>
  
  <p>When gradle runs the tests, gradle tries to inject its own logging backend. - Guess this is the part where some module access problem arise.</p>