Uploaded image for project: 'logback'
  1. logback
  2. LOGBACK-1320

Logback not capturing all log messages from JUL

    XMLWordPrintable

Details

    Description

      INFO and CONFIG messages in JUL are classified as INFO messages in Logback. FINE and FINER messages in JUL are classified as DEBUG messages in Logback. When using the LevelChangePropagator, it is expected when the Logback level is INFO that both INFO and CONFIG messages in JUL are captured. The same should be true about FINE and FINER messages when the Logback level is DEBUG.

      However, when the Logback level is INFO, CONFIG messages are not captured; while, INFO messages are. When the Logback level is DEBUG, FINER messages are not captured; while, FINE messages are. 

       

      How to Reproduce:

      I have attached my logback configuration file as well as a simple main class which logs INFO, CONFIG, FINE, FINER, and FINEST messages.

       

      Solutions:

      It appears the problem stems from JULHelper.asJULLevel() method. When the level is DEBUG, FINE is returned. When the level is INFO, then INFO is returned. This method should return FINER for DEBUG and CONFIG for INFO. I have attached a modified version of the JULHelper.

      As JULHelper.asJULLevel() is part of the public API this change may impact users that directly call this method. Therefore if you want to preserve backwards compatibility, you can add another method like asLowerJULLevel() which returns FINER and CONFIG in the appropriate place. Then in the LevelChangePropagator call asLowerJULLevel() in the propagate() method.

      Attachments

        1. JULHelper.java
          2 kB
          Nathan
        2. logback.xml
          0.4 kB
          Nathan
        3. Main.java
          0.5 kB
          Nathan

        Activity

          People

            logback-dev Logback dev list
            nlighth1 Nathan
            Votes:
            1 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: