Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

org.slf4j.LoggerFactory can not load SLF4JServiceProvider with org.eclipse.osgi.internal.loader.EquinoxClassLoader #427

Open
Holzmacher opened this issue Aug 27, 2024 · 4 comments

Comments

@Holzmacher
Copy link

Holzmacher commented Aug 27, 2024

In org.slf4j.LoggerFactory the following row:
serviceLoader = ServiceLoader.load(SLF4JServiceProvider.class, classLoaderOfLoggerFactory);
has a problem, if classLoaderOfLoggerFactory is a org.eclipse.osgi.internal.loader.EquinoxClassLoader.

Then the loaded serviceLoader has an empty loadedProviders Array.

Seee also:
https://stackoverflow.com/questions/78783619/logback-logger-1-5-0-with-eclipse-4-31-no-slf4j-providers-were-found/78904640#78904640

@ppkarwasz
Copy link
Contributor

SLF4J 2 assumes that a Service Loader Mediator like Apache SPI Fly is present in your OSGi environment. You need to add the bundle to your Equinox deployment.

@ppkarwasz
Copy link
Contributor

See also #428.

@Holzmacher
Copy link
Author

I would say it would be helpful, if you add this osgi issue to the following manual:
https://www.slf4j.org/codes.html#noProviders

Because you get following output in this case:
SLF4J(W): No SLF4J providers were found.
SLF4J(W): Defaulting to no-operation (NOP) logger implementation
SLF4J(W): See https://www.slf4j.org/codes.html#noProviders for further details.

@ceki
Copy link
Member

ceki commented Aug 30, 2024

@Holzmacher Thank you for following up on this issue. It is much appreciated.

I should observe that the code in initSLF4JServiceProvider creates a second logging system unrelated to the one used by LoggerFactory. Thus, it is not a general solution.

However, it is not clear if the first part of your answer is sufficient and whether initSLF4JServiceProvider was provided for illustration purposes only and is not actually needed.

Can you please clarify?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants