title: Logback or slf4j logging in groovy unit tests with Maven and GMaven?
body: <p>I am trying to get logging enabled in my Grovvy unit tests that I am running with Cucumber-jvm.</p>
  
  <p>In my tests I have imported:</p>
  
  <pre><code>import groovy.util.logging.Slf4j
  </code></pre>
  
  <p>Then added </p>
  
  <pre><code>@Slf4j
  </code></pre>
  
  <p>However, when I run any of these commands:</p>
  
  <pre><code>mvn test -Dgmaven.logging=DEBUG
  mvn test -Dgmaven.logging=TRACE
  </code></pre>
  
  <p>This method only prints out '[WARN] log.isWarnEnabled()'</p>
  
  <pre><code>void debugLogging(){
      println("~~~~~ debugLogging() ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~")
      if(log.isTraceEnabled()){
          println("log.isTraceEnabled()")
          log.trace("log.isTraceEnabled()")
      }
      if(log.isDebugEnabled()){
          println("log.isDebugEnabled()")
          log.debug("log.isDebugEnabled()")
      }
      if(log.isInfoEnabled()){
          println("log.isInfoEnabled()")
          log.info("log.isInfoEnabled()")
      }
      if(log.isWarnEnabled()){
          println("log.isWarnEnabled()")
          log.warn("log.isWarnEnabled()")
      }
  }
  </code></pre>
  
  <p>Here is my ./src/test/resources/logback.xml :</p>
  
  <pre><code>&lt;configuration&gt;
      &lt;appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"&gt;
          &lt;encoder&gt;
              &lt;pattern&gt;
                  %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
              &lt;/pattern&gt;
          &lt;/encoder&gt;
      &lt;/appender&gt;
  
      &lt;!-- Use level="DEBUG" for more detailed logging --&gt;
      &lt;root level="debug"&gt;
          &lt;appender-ref ref="STDOUT" /&gt;
      &lt;/root&gt;
  
  &lt;/configuration&gt;
  </code></pre>
  
  <p>How can I change the log level in my unit test?</p>