Home

SLF4J

SLF4J, or the Simple Logging Facade for Java, is a logging API that provides a common interface for various logging frameworks. It is not a logging implementation itself. Instead, it acts as a facade that delegates to a concrete backend at runtime via a binding jar. This decouples application code from the specific logging framework and allows switching implementations without changing source.

To use SLF4J, a binding must be present on the classpath that connects the SLF4J API to

The API provides methods for levels trace, debug, info, warn, and error, and supports parameterized messages

SLF4J was created by Ceki Gülcü and first released in the mid-2000s. It has become the de

Example: Logger logger = LoggerFactory.getLogger(MyClass.class); logger.info("User {} logged in", username);

a
concrete
framework
such
as
Logback,
Log4j,
java.util.logging,
or
a
no-op
implementation.
Common
bindings
include
slf4j-logback-classic,
slf4j-log4j12,
and
slf4j-simple.
using
{}
placeholders.
It
also
offers
a
Mapped
Diagnostic
Context
(MDC)
for
per-thread
contextual
data
and
supports
markers
for
advanced
filtering.
facto
standard
for
libraries
and
applications
that
want
to
remain
framework-agnostic.
The
project
is
open
source
and
released
under
the
Apache
License
2.0.