title: Logger slf4j is not using the logback configured level
body: <blockquote>
    <p><strong>Even though I have awarded the bounties to the users below that have
    attempted to help, the original question remains unanswered. No actual
    workable solution exists to ensure that the logback.groovy configured
    logging is honoured within the junit tests. The tests load up the
    logback config and it does report the correct level and yet still the
    actual test logging (exclusively through slf4j) is at ANY or TRACE
    level</strong></p>
    
    <p>I know others have encountered this same problem and it is very
    annoying when tests for big projects take a lot longer due to console
    logging being much too verbose. I cannot keep throwing bounties at
    this question. I hope someone comes up with a good solution that
    allows the tests logging to be properly configured at different levels
    through a system property. Then, different configurations can be
    created for the project so that tests will be able to configured at different logging threshold levels.</p>
  </blockquote>
  
  <p>My logging is configured by logback through a logback.groovy file</p>
  
  <p>Now, when my Maven POM project that aggregates all other projects starts, it passes them all the System property to set the correct logging level.</p>
  
  <p>However, when the junit tests run, for some reason, the logger does not pick up the correct level even though the test classes static @beforeClass ensure that logback is properly configured.</p>
  
  <p>It is not the Loggers in the tests that are the problem, -- well - yes them too-- , <strong>the real problem is that the loggers in the code sections that run (all my programs loggers everywhere) are set to the wrong logging level. They are not picking up what the logging is when the program tests are configured.</strong></p>
  
  <p>However, the projects are reporting the correct when logback initializes with the logback.goovy file. However, the actual logging level is set to TRACE or ALL</p>
  
  <p>From the output below, it is clear that logback has configured to INFO. But the first project logging statement at TRACE (last line) shows that is not being picked up.</p>
  
  <p>Help.</p>
  
  <pre><code>-------------------------------------------------------
   T E S T S
  -------------------------------------------------------
  Running groovy.text.StreamingTemplateEngineTest
  Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.245 sec
  Running net.abcd.templating.InlinerTest
  01:22:15,265 |-INFO in ch.qos.logback.classic.gaffer.ConfigurationDelegate@1e8c3cb - Added status listener of type [ch.qos.logback.core.status.OnConsoleStatusListener]
  01:22:15,290 |-INFO in ch.qos.logback.classic.gaffer.ConfigurationDelegate@1e8c3cb - Setting ReconfigureOnChangeFilter scanning period to 5 minutes
  01:22:15,290 |-INFO in ReconfigureOnChangeFilter{invocationCounter=0} - Will scan for changes in [[C:\Users\ABDC\Dropbox\workspace\abcd\AbcdTemplating\conf\logback.groovy]] every 300 seconds. 
  01:22:15,290 |-INFO in ch.qos.logback.classic.gaffer.ConfigurationDelegate@1e8c3cb - Adding ReconfigureOnChangeFilter as a turbo filter
  01:22:15,312 |-INFO in ch.qos.logback.classic.gaffer.ConfigurationDelegate@1e8c3cb - About to instantiate appender of type [ch.qos.logback.core.ConsoleAppender]
  01:22:15,316 |-INFO in ch.qos.logback.classic.gaffer.ConfigurationDelegate@1e8c3cb - Naming appender as [STDOUT]
  ***********************************************************
  
  LOGGING MODE PROPERTY 'net.abcd.logging.level' SET TO: [info]
  IT CAN BE SET TO: OFF, ERROR, WARN, INFO, DEBUG, TRACE, ALL, INFO
  
  ***********************************************************
  getLogLevel() returned 'INFO'
  01:22:15,496 |-INFO in ch.qos.logback.classic.gaffer.ConfigurationDelegate@1e8c3cb - Setting level of logger [ROOT] to INFO
  01:22:15,532 |-INFO in ch.qos.logback.classic.gaffer.ConfigurationDelegate@1e8c3cb - Attaching appender named [STDOUT] to Logger[ROOT]
  01:22:15.846 [main] TRACE net.abcd.templating.Inliner - Document:
  </code></pre>
  
  <p>My logback.groovy file is:</p>
  
  <pre><code>displayStatusOnConsole()
  scan('5 minutes')  // Scan for changes every 5 minutes.
  setupAppenders()
  setupLoggers()
  
  def displayStatusOnConsole() {
      statusListener OnConsoleStatusListener 
  }
  
  def setupAppenders() {
      appender('STDOUT', ConsoleAppender) {
          encoder(PatternLayoutEncoder) {
              pattern = "%d{HH:mm:ss.SSS} [%thread] %-5level %-16logger{50} - %msg%n"
          }
      }
  }
  
  
  def setupLoggers() {    
      def loglevel = getLogLevel() 
      println("getLogLevel() returned '${loglevel}'")
      root(loglevel, ['STDOUT'])
  }
  
  def getLogLevel() {
      def mode = System.getProperty('net.abcd.logging.level', '')
      println("***********************************************************")
      println("")
      println("LOGGING MODE PROPERTY 'net.abcd.logging.level' SET TO: [${mode}]")
      println("IT CAN BE SET TO: OFF, ERROR, WARN, INFO, DEBUG, TRACE, ALL, INFO")
      println("")
      println("***********************************************************")
      switch(mode.toLowerCase()){
      case 'off':
          return OFF
      case 'error':
          return ERROR
      case 'warn':
          return WARN
      case 'info':
          return INFO
      case 'debug':
          return DEBUG
      case 'trace':
          return TRACE
      case 'all':
          return ALL
      default:
          return INFO
      }
  }
  </code></pre>