I'm using Slf4j 1.7.x in conjunction with Logback in my applications (it is a Dropwizard-application). Now we have libraries that use the log4j2 (not log4j), and the logging goes to /dev/null
. I can't find a logj2-over-slf4j
or log4j2-to-slf4j
library in any exising maven application, what is the trick?
Log4j2 includes a log4j-to-slf4j bridge module. Any application coded against the Log4j2 API can choose to switch the backing implementation to any slf4j-compliant implementation at any time.
Migrate to SLF4J from Log4j - OpenRewrite. In this guide, we'll use OpenRewrite to perform an automated migration from Apache Log4j (handling both log4j 1. x or log4j 2. x ) to the Simple Logging Facade for Java ( SLF4J ).
So essentially, SLF4J does not replace Log4j, Both work together. SLF4j removes the tight coupling between the application and logging frameworks. It makes it easy to replace with any other logging framework in the future with a more capable library.
The answer is "No" because log4j-over-slf4j only provides the log4j API but does not contain any implementation of log4j.
You may use the Log4j 2 to SLF4J Adapter to route your Log4j2 logs to your slf4j implementation. You are right that slf4j itself does not provide an adapter for log4j2.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With