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

Move from SLF4j to Java 9+ System.Logger and provide binding for logback out of the box #7043

Open
graemerocher opened this issue Mar 10, 2022 · 8 comments
Labels
status: next major version The issue will be considered for the next major version type: improvement A minor improvement to an existing feature
Milestone

Comments

@graemerocher
Copy link
Contributor

Feature description

Since Java 9 SLF4J is no longer necessary and we should move logging to System.Logger

Ref https://www.baeldung.com/java-9-logging-api

This eliminates the need for an additional dependency

@graemerocher graemerocher added the status: next major version The issue will be considered for the next major version label Mar 10, 2022
@graemerocher graemerocher added this to the 4.0.0 milestone Mar 10, 2022
@graemerocher graemerocher added the type: improvement A minor improvement to an existing feature label Mar 10, 2022
@yawkat
Copy link
Member

yawkat commented Mar 10, 2022

I don't think this is a good idea. The System.Logger is pretty limited. Also see the JEP:

It is not a goal to define a general-purpose interface for logging. The service interface contains only the minimal set of methods that the JDK needs for its own usage.

Also, since System.Logger does not provide an implementation on its own, we would still need logback, which requires slf4j anyway.

@graemerocher
Copy link
Contributor Author

Yeah it is just here for consideration, it is pretty obvious at runtime slf4j and logback would still be needed, but if that could be made an optional dependency it means less is needed.

The question is do we need any of the features of these libraries in Micronaut Core.

It is clear that certain features (MDC comes to mind) are required for production level applications

@yawkat
Copy link
Member

yawkat commented Mar 10, 2022

We could also make our own logging adapter at that point

@rbygrave
Copy link

FYI:

Some comments about System.Logger by Stuart Marks on Twitter: https://mobile.twitter.com/stuartmarks/status/1254819581585047552

It's mainly for the JDK itself, but it can also be used by anything that doesn't want to add a dependency for a logging facade.

The primary consumer is the JDK, but it’s public so anyone can use it. It seems useful for libraries that want to minimize dependencies.

That said, if one can live within the limitations of System.Logger, it's public, so it's fine for anyone to use.

@sschuberth
Copy link

Also, since System.Logger does not provide an implementation on its own

Just for reference, that's not quite correct. System.Logger defaults to JUL as a backend. But granted, JUL is very limited in its capabilities.

@stefanofornari
Copy link

stefanofornari commented Apr 13, 2024

I wonder which are such cool features in other logging frameworks not available in JUL and used in micronaut... Log4J vulnerability CVE-2021-45046 teaches to keep logging simple

@yawkat
Copy link
Member

yawkat commented Apr 15, 2024

@stefanofornari slf4j is a facade that allows users to pick their own logging framework. This is much more difficult with JUL. We do not want to force people to use JUL over other, more capable frameworks like logback.

@sideeffffect
Copy link

The real question is what are the logging facade features that Micronaut needs that are not available in System.Logger.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: next major version The issue will be considered for the next major version type: improvement A minor improvement to an existing feature
Projects
Development

No branches or pull requests

6 participants