SLF4J

Last updated
Simple Logging Facade for Java
Developer(s) Ceki Gülcü
Stable release
2.0.17 / February 25, 2025;5 months ago (2025-02-25) [1]
Repository
Written in Java
Operating system Cross-platform
Type Logging Tool
License MIT License
Website www.slf4j.org

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]

Contents

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

LOG.debug("There are now "+count+" user accounts: "+userAccountList);// slowerLOG.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

References

  1. "SLF4J News". slfj4.org. 2025-02-25.
  2. java.util.logging
  3. logback
  4. tinylog
  5. "SLF4J binding for tinylog". Archived from the original on 2017-12-07. Retrieved 2014-12-16.
  6. "Think again before adopting the commons-logging API"
  7. "Taxonomy of class loader problems encountered when using Jakarta Commons Logging"
  8. "We Analyzed 30,000 GitHub Projects – Here Are The Top 100 Libraries in Java, JS and Ruby". Archived from the original on 2014-07-09. Retrieved 2014-02-09.
  9. Nicolas, Frenkel. ""most popular" section". Twitter. Retrieved 2022-01-16.
  10. SLF4J api docs: Logger
  11. Apache log4j 2.x slf4j Binding
  12. "SLF4J News". www.slf4j.org. Retrieved 2023-11-27.