[slf4j-dev] [JIRA] Updates for SLF4J-544: LoggerFactory only loads services from context class loader

QOS.CH (JIRA) noreply-jira at qos.ch
Fri Mar 4 15:37:00 CET 2022


SLF4J / SLF4J-544 [Open]
LoggerFactory only loads services from context class loader

==============================

Here's what changed in this issue in the last few minutes.
This issue has been created
This issue is now assigned to you.

View or comment on issue using this link
https://jira.qos.ch/browse/SLF4J-544

==============================
 Issue created
------------------------------

Tobias Hotz created this issue on 04/Mar/22 3:25 PM
Summary:              LoggerFactory only loads services from context class loader
Issue Type:           Bug
Affects Versions:     1.8.0-beta4, 2.0.0-alpha6
Assignee:             SLF4J developers list
Components:           Core API
Created:              04/Mar/22 3:25 PM
Priority:             Minor
Reporter:             Tobias Hotz
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|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.


==============================
 This message was sent by Atlassian Jira (v8.8.0#808000-sha1:e2c7e59)



More information about the slf4j-dev mailing list