[slf4j-dev] [Bug 90] New: Missing check for isLoggable in slf4j-jdk14

bugzilla-daemon at pixie.qos.ch bugzilla-daemon at pixie.qos.ch
Thu Jun 19 19:04:23 CEST 2008


http://bugzilla.slf4j.org/show_bug.cgi?id=90

           Summary: Missing check for isLoggable in slf4j-jdk14
           Product: SLF4J
           Version: 1.5.x
          Platform: Macintosh
        OS/Version: Mac OS X 10.0
            Status: NEW
          Severity: blocker
          Priority: P1
         Component: Unspecified
        AssignedTo: dev at slf4j.org
        ReportedBy: matthew at mastracci.com


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);
    }
  }


-- 
Configure bugmail: http://bugzilla.slf4j.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.



More information about the slf4j-dev mailing list