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

LOG4J_SLF4J_IMPL vs. LOG4J_SLF4J2_IMPL for enforceLog4J2() #121

Open
Vampire opened this issue Apr 15, 2024 · 3 comments
Open

LOG4J_SLF4J_IMPL vs. LOG4J_SLF4J2_IMPL for enforceLog4J2() #121

Vampire opened this issue Apr 15, 2024 · 3 comments
Assignees
Labels
a:bug Something isn't working in:logging Things related to 'logging { }' DSL

Comments

@Vampire
Copy link
Contributor

Vampire commented Apr 15, 2024

Calling enforceLog4J2() chooses LOG4J_SLF4J_IMPL as slf4j impl.
Wouldn't it be more appropriate to select LOG4J_SLF4J2_IMPL?

@jjohannes jjohannes added the in:logging Things related to 'logging { }' DSL label Apr 23, 2024
@britter britter added the a:bug Something isn't working label Apr 26, 2024
@ljacomet ljacomet added this to the 2.1 milestone Apr 26, 2024
@ljacomet
Copy link
Contributor

According to the documentation, this depends on the version of slf4j in use.

I need to check what can be done there and whether this decision can be made automatically or if the user will need to make a choice. In the previous version of this plugin, I had an issue for this.

I am going to move this out of the 2.1 release as it is a bigger piece of work.

@ljacomet ljacomet removed this from the 2.1 milestone May 25, 2024
@Vampire
Copy link
Contributor Author

Vampire commented May 25, 2024

Well, if you select log4j-slf4j-impl and anything in the build uses slf4j 2, it will not work, as the discovery changed from including a class with specific FQCN to a proper way.

If you select log4j-slf4j2-impl, this depends on slf4j 2 and thus upgrades the slf4j version if only 1.7 was used, so should work in both cases.

I think the the only potentially unwanted effect should be that slf4j is updated to 2+ when it could stay on 1.7, but why should what be a problem? And if it is one could still manually change configuration.

@Vampire
Copy link
Contributor Author

Vampire commented May 25, 2024

The slf4j docs even explicitly state

From the client's perspective the slf4j-api, more specifically classes in the org.slf4j package, are backward compatible for all versions. Client code compiled with slf4j-api-N.jar will run perfectly fine with slf4j-api-M.jar for any N and M. You only need to ensure that the version of your provider/binding matches that of the slf4j-api.jar. You do not have to worry about the version of slf4j-api.jar used by a given dependency in your project.

So as adding the log4j-slf4j2-impl will also updating the slf4j-api, all should be fine.

The only thing is, that you break Java 5 - 7 compatibility which was supported by 1.7 but no longer in 2+, but honestly, ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a:bug Something isn't working in:logging Things related to 'logging { }' DSL
Projects
None yet
Development

No branches or pull requests

4 participants