Simple Logging Facade
- A single API to abstract various logging frameworks
- Parameters are interpolated into message efficiently
- Libraries depend only to
slf4j-api
- Applications provide the logging backend at deploy time (noop, simple, jul, log4j, logback)
Sample code
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
final Logger logger = LoggerFactory.getLogger(Example.class);
logger.info("A message with param {} and {}", a, b);
Bindings
Forwarding logs to logback

Forwarding logs to log4j

Technical notes
- The SLF4J API supports parametrization in the presence of an exception, assuming the exception is the last parameter (see FAQ)
- By setting the
slf4j.detectLoggerNameMismatch
system property SLF4J can automatically spot incorrectly named loggers (see Detected logger name mismatch)
- There is a migrator tool