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

Start using slf4j for logging instead of java.util.logging #456

Closed
payurgin opened this issue Sep 17, 2020 · 2 comments
Closed

Start using slf4j for logging instead of java.util.logging #456

payurgin opened this issue Sep 17, 2020 · 2 comments

Comments

@payurgin
Copy link

It's easy to use slf4j as abstraction over concrete logging framework: logback, log4j, java.util.logging. All we need is to add jar on classpath: http://slf4j.org/manual.html

Motivation:

We want to use caffeine in library code, but it is currently not possible to disable logging for caffeine in library layer.
Application not using java.util.logging should to do something [that] (https://stackoverflow.com/questions/6020545/send-redirect-route-java-util-logging-logger-jul-to-logback-using -slf4j) just to disable caffeine logs.

I think it would be simpler with slf4j as logging facade. WDYT ?

@ben-manes
Copy link
Owner

We log minimally, ideally not at all, and primarily only warnings that do not affect the cache's correctness. The primary time you might observe logging is due to a convenience warning when an AsyncCache future is removed due to an error. An unfortunately common mistake is to forget to include an error handler on a CompleteableFuture and then wonder why the cache entry disappeared.

Currently Caffeine mirror's Google Guava which uses JUL. It's generally good practice to install the adapters from other loggers to slf4j as a fallback. For example I use logback at work but have log4j, jul, and system out/err redirect to slf4j.

The next major version will use JEP-264: Platform Logging API, which avoids the dependency, is backwards compatible by defaulting to JUL, and has a cleaner mechanism for redirecting to slf4j. However that requires Java 9.

@ben-manes
Copy link
Owner

Released in 3.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants