Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Log4j 2.0 and SLF4J and the never ending future of java logging frameworks [closed]

So I just found out today that Log4J 2.0 is now actively being developed, there is an alpha version and it is said to replace logback.

Right now in my app I have close to 4 maybe more logging frameworks:

  • Java Util Logging
  • log4j
  • slf4j
  • logback (ignored thanks to a maven provided hack)
  • commons logging (ignored thanks to a maven provided hack)
  • And tomcat has its own JULI adapter

I have been using log4j (1.2.x) because frankly I just haven't needed the features of the newer guys but I have been tempted lately to switch to SLF4J and mainly because I don't want to have rewrite my complicated log4j configurations files to a new format (logback).

Now my question is in terms of what I should code against is SLF4J the right choice for the future given log4j 2.0.

It seems like I should just stick with old log4j (1.2.x) as it is the lowest common denominator?

UPDATE: on further examination of log4j 2.0 while very similar it appears the configuration is not backward compatible with log4j 1.2. Looks like logback is the best choice.

like image 354
Adam Gent Avatar asked Aug 23 '12 14:08

Adam Gent


People also ask

Does log4j over SLF4J use log4j?

SLF4J ship with a module called log4j-over-slf4j. It allows log4j users to migrate existing applications to SLF4J without changing a single line of code but simply by replacing the log4j. jar file with log4j-over-slf4j.

Can SLF4J replace log4j?

Conclusion. 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 SLF4J deprecated?

The class org. slf4j. ext. EventData is now marked as deprecated in preparation for its removal due to a security vulnerability.

Is log4j over SLF4J vulnerable?

As such, using log4j 2. x, even via SLF4J does not mitigate the vulnerability. However, as mentioned already, log4j 1. x is safe with respect to CVE-2021-44228.


1 Answers

Disclaimer: I am the founder of log4j, slf4j and logback projects but unaffiliated with log4j 2.0.

As I understand it, notwithstanding its name, log4j 2.0 is very different than log4j 1.x. As far as the user API is concerned, log4j 2.0 is largely incompatible with log4j 1.x. Log4j 2.0 provides an adaptation layer for log4j 1.x which at present time (2012-08) is undocumented.

like image 113
Ceki Avatar answered Oct 13 '22 07:10

Ceki