I have read similar questions on SO like this and this. But they are about four years old!
Also I have read this logback page, which has some really good info on why to choose Logback over log4j.
I am looking to implement a logging framework for a project with the following technology stack -
I have already decided to use slf4j as the facade, so this question is on whether to use slf4j + log4j or slf4j + logback (I know that logback natively uses slf4j).
What I am looking for is following -
EDIT: I've read at many places (one of the answer below states this as well) that log4j is dead/deprecated. Contrary to that, log4j just released an alpha version of its 2.0 release. So I do not buy that argument.
Key Difference Between Log4j vs LogbackAs logback is improved, version log4j and versions log4j2 and logback have no difference in terms of performance or any features. Therefore log4j is the most used logging utility before the logback newer versions were invented.
Logback is one of the most widely used logging frameworks in the Java Community. It's a replacement for its predecessor, Log4j. Logback offers a faster implementation, provides more options for configuration, and more flexibility in archiving old log files.
As the slf4j documentation says, you just have to replace all the log4j dependencies with a single one from slf4j, named log4j-over-slf4j: http://slf4j.org/legacy.html#log4j-over-slf4j. Any code that is under your direct control can just use slf4j + logback as it always would.
LogBack successes Log4J, it is from the author who made Log4J. Log4J is currently deprecated.
Here is an example of where SLF4J / LogBack primes:
Log4J (Current)
Object entry = new SomeObject();
logger.debug("The new entry is "+entry+".");
Here are the tasks performed:
SLF4J / LogBack (New)
Object entry = new SomeObject();
logger.debug("The new entry is {}.", entry);
Here are the tasks performed:
http://www.slf4j.org/faq.html#logging_performance
Ability to replace tomcat-default jul logging with logback/log4j loggin?
Yes, use with SLF4J.
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