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

LoggerFactory only loads services from context class loader

    XMLWordPrintable

Details

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • 2.0.4, 2.0.5
    • 1.8.0-beta4, 2.0.0-alpha6
    • Core API
    • None

    Description

      SLF4J currently uses services loader to find a implementation to bind (See https://github.com/ichttt/slf4j/blob/74ccf20fab1a35243ae41c2f56f2167e86afbd0c/slf4j-api/src/main/java/org/slf4j/LoggerFactory.java#L101)

      This can cause issues with certain module classloading setups where the context classloader does not contain any module that has a slf4j implementation, but the classloader of the LoggerFactory class might be different from the context classloader and contain a module that has a slf4j implementation.

      My suggestion would be to expand findServiceProviders so it also class ServiceLoader.load with the class loader of LoggerFactory (if it is different from the context classloader) and add this to the list as well.

      This would not change existing behaviour if an implementation can be found with the context classloader, as slf4j always uses the first entry in the list returned by LoggerFactory.findServiceProviders.

      Attachments

        Activity

          People

            ceki Ceki Gülcü
            ichttt Tobias Hotz
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: