Description
Hi,
First of all congratulations and thank you for this excellent API.
I want to use your Slf4j API in my JDBC driver for the Uno LibreOffice / OpenOffice API. I want to use it to redirect loggers from HsqlDB and H2 to the Uno Logger API, but I can't use it without modifying the slf4j-api.jar service loader. Let me explain my problem.
Services provider or plugins seem to be loaded in the file:
with the commande:
ServiceLoader<SLF4JServiceProvider> serviceLoader = ServiceLoader.load(SLF4JServiceProvider.class);
but without ClassLoader who is by default the current Thread's ClassLoader.
My application, a jar file that embeds the Slf4j API and a service provider for the Uno Logger archives (slf4j-api.jar and UnoLogger.jar), that wants to use Slf4j is loaded by a URLClassLoader by LibreOffice which extend the CLASSPATH and which has as ClassLoader the current Thread's ClassLoader.
As a result, Services or Plugins can't never see the extended CLASSPATH from my application and never load...
Would it be possible to load the services with the ClassLoader of the caller:
ServiceLoader<SLF4JServiceProvider> serviceLoader = ServiceLoader.load(SLF4JServiceProvider.class, LoggerFactory.class.getClassLoader());
instead of that of the current Thread.
This will allow CLASSPATH inheritance through ClassLoaders... and this is the normal behaviour of
new Object()
or
Class.forName()
Thank you.
Attachments
Issue Links
- duplicates
-
SLF4J-544 LoggerFactory only loads services from context class loader
- Resolved
- links to