SLF4J explained

Simple Logging Facade for Java
Developer:Ceki Gülcü
Latest Release Version:2.0.9
Latest Release Date:[1]
Programming Language:Java
Operating System:Cross-platform
Genre:Logging Tool
License:MIT License

Simple Logging Facade for Java (SLF4J) provides a Java logging API by means of a simple facade pattern. The underlying logging backend is determined at runtime by adding the desired binding to the classpath and may be the standard Sun Java logging package java.util.logging,[2] Log4j, Reload4j, Logback[3] or tinylog.[4] [5]

The separation of the client API from the logging backend reduces the coupling between an application and any particular logging framework. This can make it easier to integrate with existing or third-party code or to deliver code into other projects that have already made a choice of logging backend.

SLF4J was created by Ceki Gülcü as a more reliable alternative to Jakarta Commons Logging framework.[6] [7] Research in 2013 on 10,000 GitHub projects found that the most popular Java library is SLF4J, along with JUnit, with 30.7% of projects using it.[8] In January 2021, it was ranked as the second most popular project according to mvnrepository.[9]

Similarities and differences with log4j 1.x

private static final Logger LOG = LoggerFactory.getLogger(Wombat.class);

LOG.debug("There are now " + count + " user accounts: " + userAccountList); // slower LOG.debug("There are now user accounts: ", count, userAccountList); // faster

Similarities and differences with log4j 2.x

Apache log4j 2.x supports all slf4j features.[11]

Version history

Version 2

Version 2.0.0 was released on 2022-08-20. The latest version 2 release is 2.0.9 (2023-09-03).[12]

Significant changes and feature additions:

Version 1

Version details can be found in the manual.

Significant versions include:

See also

Notes and References

  1. Web site: SLF4J News . slfj4.org . en . 2023-09-03.
  2. http://java.sun.com/javase/6/docs/api/java/util/logging/package-summary.html java.util.logging
  3. http://logback.qos.ch/ logback
  4. http://www.tinylog.org/ tinylog
  5. Web site: SLF4J binding for tinylog . 2014-12-16 . 2017-12-07 . https://web.archive.org/web/20171207070817/http://www.tinylog.org/news#29 . dead .
  6. http://articles.qos.ch/thinkAgain.html "Think again before adopting the commons-logging API"
  7. http://articles.qos.ch/classloader.html "Taxonomy of class loader problems encountered when using Jakarta Commons Logging"
  8. Web site: We Analyzed 30,000 GitHub Projects – Here Are The Top 100 Libraries in Java, JS and Ruby . 2014-02-09 . 2014-07-09 . https://web.archive.org/web/20140709221250/http://www.takipiblog.com/2013/11/20/we-analyzed-30000-github-projects-here-are-the-top-100-libraries-in-java-js-and-ruby/ . dead .
  9. Web site: Nicolas. Frenkel. "most popular" section. 2022-01-16. Twitter. en.
  10. https://slf4j.org/apidocs/org/slf4j/Logger.html SLF4J api docs: Logger
  11. https://logging.apache.org/log4j/2.x/log4j-slf4j-impl/index.html Apache log4j 2.x slf4j Binding
  12. Web site: SLF4J News . 2023-11-27 . www.slf4j.org.