Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bridging from log4j2 to slf4j

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?

like image 992
Dag Avatar asked Jun 26 '15 10:06

Dag


People also ask

Is slf4j compatible with Log4j2?

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.

How do I convert log4j-to-slf4j?

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 ).

Can we replace log4j with 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.

Is log4j-to-slf4j affected by log4j vulnerability?

The answer is "No" because log4j-over-slf4j only provides the log4j API but does not contain any implementation of log4j.


1 Answers

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.

like image 183
Torsten Avatar answered Sep 29 '22 23:09

Torsten