[slf4j-dev] [Bug 290] New: StaticLoggerBinder shold not swallow Errors

bugzilla-daemon at qos.ch bugzilla-daemon at qos.ch
Thu Jan 24 11:19:00 CET 2013


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

           Summary: StaticLoggerBinder shold not swallow Errors
           Product: SLF4J
           Version: 1.7.x
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: blocker
          Priority: P1
         Component: Core API
        AssignedTo: slf4j-dev at qos.ch
        ReportedBy: david at davidkarlsen.com


I'm creating a custom Logback StatusListener which raises java.lang.Errors in
case of severe logging issues (e.g. IOErrors) so that I can disable normal
operation of my application in these situations.

This works fine when I get an IOError after the application has started to run
and loggers are bound (for instance when a filesystem becomes full).

HOWEVER - it would not work for a non-writable file as slf4j/logback
initializes, due to StaticLoggerBinders init() behaviour, which catches
Throwable and simply logs this:

 void init() {
    try {
      try {
        new ContextInitializer(defaultLoggerContext).autoConfig();
      } catch (JoranException je) {
        Util.report("Failed to auto configure default logger context", je);
      }
      StatusPrinter.printInCaseOfErrorsOrWarnings(defaultLoggerContext);
      contextSelectorBinder.init(defaultLoggerContext, KEY);
      initialized = true;
    } catch (Throwable t) {
      // we should never get here
      Util.report("Failed to instantiate [" + LoggerContext.class.getName()
          + "]", t);
    }
  }


I think this should be changed to a catch ( Exception ) as it's not good
behaviour to catch Errors (and certainly not when not rethrowing them).

Alternatively keep the catch block as today, but if t instanceof Error rethrow
the Error.

using slf4j-api 1.7.2 and logback 1.0.9

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


More information about the slf4j-dev mailing list