Uploaded image for project: 'SLF4J'
  1. SLF4J
  2. SLF4J-81

Missing check for isLoggable in slf4j-jdk14

    XMLWordPrintable

Details

    • Icon: Bug Bug
    • Resolution: Fixed
    • None
    • 1.5.x
    • Unspecified
    • None
    • Operating System: Mac OS X 10.0
      Platform: Macintosh

    Description

      The generic log method in slf4j-jdk14 is missing a wrapper to test if the level is loggable:

      if (logger.isLoggable(julLevel)) {

      Without it, the stack trace elements are getting created from org.apache.commons.logging.impl.SLF4JLocationAwareLog unconditionally.

      I suggest changing this method as follows:

      public void log(Marker marker, String callerFQCN, int level, String message,
      Throwable t) {
      Level julLevel;
      switch (level)

      { case LocationAwareLogger.TRACE_INT: julLevel = Level.FINEST; break; case LocationAwareLogger.DEBUG_INT: julLevel = Level.FINE; break; case LocationAwareLogger.INFO_INT: julLevel = Level.INFO; break; case LocationAwareLogger.WARN_INT: julLevel = Level.WARNING; break; case LocationAwareLogger.ERROR_INT: julLevel = Level.SEVERE; break; default: throw new IllegalStateException("Level number " + level + " is not recognized."); }

      if (logger.isLoggable(julLevel))

      { log(callerFQCN, julLevel, message, t); }

      }

      Attachments

        Activity

          People

            slf4j-dev SLF4J developers list
            matthew@mastracci.com Matthew Mastracci
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: