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

SLF4J 2: add a service provider #155

Closed
wants to merge 4 commits into from
Closed

Conversation

vitalijr2
Copy link
Contributor

@vitalijr2 vitalijr2 commented Sep 21, 2022

New version of SLF4J uses service providers instead of static binders, see What has changed in SLF4J version 2.0.0?

This PR adds a service provider.

Important: 2.0.1 has outdated javadoc in SimpleLogger.handleNormalizedLoggingCall
I think we have to wait of v2.0.2. I have created the related issue SLF4J-564. So at least one another commit is needed.

Closes #152

@slawekjaranowski
Copy link
Member

@radio-rogal Thanks for PR.

slf4j 2.0.2 was released

Maybe we should put dependency to slf4j as optional/provided dependency in order to not preserver specific version of caller.

@slawekjaranowski slawekjaranowski added the enhancement New feature or request. label Sep 22, 2022
@vitalijr2
Copy link
Contributor Author

slf4j 2.0.2 was released

Przepraszam, I haven't update a comment: 2.0.2 was released yesterday and my javadoc fix late a little :(

I hope it will be fixed in 2.0.3.

@vitalijr2
Copy link
Contributor Author

Maybe we should put dependency to slf4j as optional/provided dependency in order to not preserver specific version of caller.

slf4j-simple has different packages in 1.7.* (org.slf4j.impl) and 2.0.* (org.slf4j.simple), see commits
qos-ch/slf4j@1c13755 add org.sfl4j.simple
qos-ch/slf4j@6ac20c6 "remove org.slf4j.impl package - fixes SLF4J-407"

@slawekjaranowski
Copy link
Member

We can exclude SimpleLogger from javadoc - it is copied from slf4j source.

@slawekjaranowski
Copy link
Member

Maybe we should put dependency to slf4j as optional/provided dependency in order to not preserver specific version of caller.

slf4j-simple has different packages in 1.7.* (org.slf4j.impl) and 2.0.* (org.slf4j.simple), see commits qos-ch/slf4j@1c13755 add org.sfl4j.simple qos-ch/slf4j@6ac20c6 "remove org.slf4j.impl package - fixes SLF4J-407"

It is not package problem, but transitive dependencies.
If someone have in project slf4j 1.7.x and add library as next test dependencies will can happen that version 2.0.x will wins.
So therefore is my proposition to change dependency to slf4j to optional.

@vitalijr2
Copy link
Contributor Author

vitalijr2 commented Sep 22, 2022

Static binder must stay in org.sfl4j.impl. I forgot it when ranamed the package impl to simple (details there #155 (comment))

Maybe I make new PR with one-commit changes, do I?

@sonarqubecloud
Copy link

SonarCloud Quality Gate failed.    Quality Gate failed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 4 Code Smells

66.7% 66.7% Coverage
0.0% 0.0% Duplication

@slawekjaranowski
Copy link
Member

Thanks, I will try to test more deeper at the weekend.

@slawekjaranowski
Copy link
Member

I tried this PR with project which has 1.7.x as dependency ... and

Caused by: java.lang.NoClassDefFoundError: org/slf4j/helpers/LegacyAbstractLogger
...
	at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
	at org.simplify4u.slf4jmock.SimpleLogger.<init>(SimpleLogger.java:36)
	at org.simplify4u.slf4jmock.mockito.LoggerAnnotationEngine.<clinit>(LoggerAnnotationEngine.java:47)
...

LegacyAbstractLogger was introduced in 2.x ...

IHMO the best way to resolve such problems it can be introducing new branch and new artifacts like slf4j2-mock

What do you think?

@slawekjaranowski
Copy link
Member

or split project for multi modules

  • commons for mocking
  • slf4j-mock - for 1.7
  • slf4j2-mock - for 2.x

@slawekjaranowski
Copy link
Member

I will try with multi module

@slawekjaranowski
Copy link
Member

@radio-rogal please look at #157

I hope after it we can simply add next module for slf4j 2.x

@slawekjaranowski
Copy link
Member

This one is out of date

@vitalijr2 vitalijr2 deleted the slf4j-2 branch September 27, 2022 12:54
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

Successfully merging this pull request may close these issues.

SLF4J 2
2 participants