Showing posts with label logging. Show all posts
Showing posts with label logging. Show all posts

November 11, 2017

Difference between SLF4J and LOG4J

SLF4J is basically an abstraction layer. It is not a logging implementation. It means that if you're writing a library and you use SLF4J, you can give that library to someone else to use and they can choose which logging implementation to use with SLF4J e.g. log4j or the Java logging API. It helps prevent projects from being dependent on lots of logging APIs just because they use libraries that are dependent on them.
So, to summarise: SLF4J does not replace log4j, they work together. It removes the dependency on log4j from your library/app.
Take a look here: http://www.slf4j.org/, or even here: http://commons.apache.org/logging/ (Apache Commons Logging is similar to SLF4J) for more info on this concept.

The Simple Logging Facade for Java (SLF4J) serves as a simple facade or abstraction for various logging frameworks (e.g. java.util.logging, logback, log4j) allowing the end user to plug in the desired logging framework at deployment time.

If you using SLF4J along with Log4j, if required Log4j can be swapped with another logging framework like Logback without compiling the source code. Logback is the reference implementation for SLF4J.
Read more ...

My Favorite Site's List

#update below script more than 500 posts