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

Obtaining a logger before loggerFactory is assigned

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Resolution: Fixed
    • Affects Version/s: 1.5.x
    • Fix Version/s: None
    • Component/s: Core API
    • Labels:
      None
    • Environment:

      Operating System: All
      Platform: All

      Description

      This issue was first identified in http://jira.qos.ch/browse/LBCORE-47
      While it is reported in the logback project, it is also an SLF4J issue.

      The problem can be described as follows:

      1) In the static initializer of the LoggerFactory class, the result of
      StaticLoggerBinder.SINGLETON.getLoggerFactory() is assigned to the
      loggerFactory variable

      2) the StaticLoggerBinder.SINGLETON.getLoggerFactory() call,
      instantiates a logback LoggerContext which proceeds with
      auto-initialization.

      3) auto-initialization reads the config file which creates a some component X

      4) component X class performs logging via commons-logging, using the jcl-over-slf4j implementation. However, at this stage the loggerFactory variable is not yet assigned. Hence the error.

      Solution: Set loggerFactory variable to NOPLoggerFactory before the line
      loggerFactory = StaticLoggerBinder.SINGLETON.getLoggerFactory()

        Attachments

          Activity

            People

            Assignee:
            slf4j-dev SLF4J developers list
            Reporter:
            listid@qos.ch Ceki Gulcu
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: