Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [cross-project-issues-dev] Help switching to SLF4J 2.0.9

Patrick,

I would suggest opening a discussion here:

  https://github.com/orgs/eclipse-orbit/discussions

That way all the information will be gathered in one place for future reference.

Our resident expert here is Hannes Wellmann.  I believe he got this working for both the Platform and for m2e.   I don't know what magic is all involved, but things like this in the product configuration are important:

The spifly thing and start levels are definitely key components to getting this to work.

If you open a discussion, I'll ask Hannes to share his experience and wisdom there...

Regards,
Ed

On 02.11.2023 14:59, Patrick Tasse via cross-project-issues-dev wrote:
In 2023-12 our project is switching our SLF4J dependencies,
from: org.slf4j.api/org.slf4j.binding.simple 1.7.30 from 2023-06 Orbit repo
to: slf4j.api/slf4j.simple 2.0.9 from 2023-12 Orbit aggregation repo

After the switch, the slf4j.simple binding no longer seems to be found by the LoggerFactory.

SLF4J: No SLF4J providers were found.
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See https://www.slf4j.org/codes.html#noProviders for further details.

Debugging, it seems that the logger factory is trying to find the bindings with ServiceLoader.load(SLF4JServiceProvider.class, classLoaderOfLoggerFactory), where the class loader is an EquinoxClassLoader[slf4j.api].

This should find SimpleServiceProvider from slf4j.simple bundle, but it does not. With test code I can also see that the slf4j.api Equinox class loader is not able to find the SimpleServiceProvider class.

What I noticed is that, in SLF4J 1.7.30, the org.slf4j.binding.simple is actually a fragment plugin with org.slf4j.api as the fragment-host. But in SLF4J 2.0.9, slf4j.simple is no longer a fragment of slf4j.api. This might explain why its class loader can no longer find the service from another plugin?

It so happens that in our project we have a fragment plugin of org.slf4j.api whose only purpose is to provide the simplelogger.properties resource, as this file must also be found by the org.slf4j.api class loader at initialization. So I tried adding the slf4j.simple as a dependency of our fragment plugin. This makes it now possible for the slf4j.api class loader to load the SimpleServiceProvider class in my test code. But the LoggerFactory still isn't able to find it using the ServiceLoader. Maybe ServiceLoader doesn't work with plugin fragments?

Does anyone have any idea how this is supposed to work? I don't know what I'm doing wrong. But then again, I know nothing, Jon Snow.

I read this: https://www.slf4j.org/faq.html#changesInVersion200, it just says both plugins must be in the classpath. I do see them in the Classpath of my test plugin (through Plug-In Dependencies), but slf4j.simple is presumably not in the classpath of the default slf4j.api plugin? And there are no Java Build Path properties for fragment plugins.

Thanks for any help,
Patrick


_______________________________________________
cross-project-issues-dev mailing list
cross-project-issues-dev@xxxxxxxxxxx
To unsubscribe from this list, visit https://www.eclipse.org/mailman/listinfo/cross-project-issues-dev

Back to the top