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

Doesn't seem to work on modern SLF4J #3

Open
Derkades opened this issue Apr 28, 2021 · 3 comments
Open

Doesn't seem to work on modern SLF4J #3

Derkades opened this issue Apr 28, 2021 · 3 comments
Labels
enhancement New feature or request

Comments

@Derkades
Copy link

[15:04:24 WARN]: SLF4J: No SLF4J providers were found.
[15:04:24 WARN]: SLF4J: Defaulting to no-operation (NOP) logger implementation
[15:04:24 WARN]: SLF4J: See http://www.slf4j.org/codes.html#noProviders for further details.
[15:04:24 WARN]: SLF4J: Class path contains SLF4J bindings targeting slf4j-api versions prior to 1.8.
[15:04:24 WARN]: SLF4J: Ignoring binding found at [jar:file:/path/to/jar!/path/in/jar/lib/slf4j/impl/StaticLoggerBinder.class]
[15:04:24 WARN]: SLF4J: See http://www.slf4j.org/codes.html#ignoredBindings for an explanation.

Newer SLF4J versions, while officially still in beta, are required for compatibility with newer JDK versions. For example, modern Jetty versions use JLF4J 2.0.0-alpha

@Derkades
Copy link
Author

Looking into it, it might not even be possible. Using serviceloaders requires specifying the plugin classloader but slf4j has the default classloader hardcoded

@Derkades
Copy link
Author

Ok, I finally figured it out. What I needed to do to get slf4j-simple working on bukkit (with relocations):

  1. exclude org/slf4j/LoggerFactory.class from slf4j-api and the file in META-INF/services from slf4j-simple to avoid conflicts
  2. relocate both
  3. create my own LoggerFactory file which has this line modified with a second parameter: the plugin's classloader
  4. create resource META-INF/services/my.plugin.lib.sjf4j.spi.SLF4JServiceProvider with contents my.plugin.lib.slf4j.simple.SimpleServiceProvider

These steps should mostly apply to your slf4j implementation as well, but I have spent too much time looking at loggers for now and went with slf4j-simple.

ServerSelectorX/ServerSelectorX@a441906

@BrainStone BrainStone added the enhancement New feature or request label Apr 28, 2021
@BrainStone
Copy link
Member

While I don't see an immediate need to act I'll kep this open/around.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Development

No branches or pull requests

2 participants