Simple Logging Facade for Java (SLF4J)

The Simple Logging Facade for Java or (SLF4J) is intended to serve as a simple facade for various logging APIs allowing to the end-user to plug in the desired implementation at deployment time. SLF4J also allows for a gradual migration path away from Jakarta Commons Logging (JCL).

SLF4J API offers an advanced abstraction of various logging systems, including JDK 1.4 logging, log4j and logback. Features include parameterized logging and MDC support.

Logging systems can either choose to implement the the SLF4J interfaces directly, à la logback or SimpleLogger. Alternatively, it is possible (and rather easy) to write SLF4J adapters for a given API implementation, e.g. Log4jLoggerAdapter or JDK14LoggerAdapter..

Simplicity

The SLF4J interfaces and their various adapters are simple and straightforward. Most developers familiar with the Java language should be able to read and fully understand the code in less than one hour.

SLF4J does not rely on any special class loader machinery. In fact, the binding between SLF4J and a given logging API implementation is performed statically at compile time of each binding. Each binding is hardwired to use one and only one specific logging API implementation. Each binding corresponds to one jar file. In your code, in addition to slf4j-api.jar, you simply drop the binding of your choice, that is a jar file, onto the appropriate class path location. As a consequence of this simple approach, SLF4J suffers from none of the class loader problems or memory leaks observed with Jakarta Commons Logging (JCL).

We hope that simplicity of the SLF4J interfaces and the deployment model will make it easy for developers of other logging APIs to conform to the SLF4J model.

Projects depending on SLF4J

Here is a non-exhaustive list of projects currently depending on SLF4J, in alphabetical order: