SLF4J
Recipes related to Simple Logging Facade for Java (SLF4J
).
Composite Recipes
Recipes that include further recipes, often including the individual recipes below.
- Migrate Apache Commons Logging 1.x to SLF4J 1.x
- Migrate JUL to SLF4J
- Migrate Log4j 1.x to SLF4J 1.x
- Migrate Log4j 2.x to SLF4J 1.x
- Migrate Log4j to SLF4J
- Parameterize SLF4J's logging statements
- Replace JUL Logger creation with SLF4J LoggerFactory
- Replace JUL active Level check with corresponding SLF4J method calls
- Replace JUL active Level check with corresponding SLF4J method calls
- Replace JUL
log(Level, String, Throwable)
with corresponding SLF4J method calls - Replace JUL
log(Level, Throwable, Supplier<String>)
with corresponding SLF4J method calls - SLF4J best practices
Recipes
- Change SLF4J log level
- Enhances logging of exceptions by including the full stack trace in addition to the exception message
- Loggers should be named for their enclosing classes
- Replace JUL
Level.ALL
logging with SLF4J's trace level - Replace JUL
Logger.config(Supplier<String>)
with SLF4J'sLogger.atInfo().log(Supplier<String>)
- Replace JUL
Logger.fine(Supplier<String>)
with SLF4J'sLogger.atDebug().log(Supplier<String>)
- Replace JUL
Logger.finer(Supplier<String>)
with SLF4J'sLogger.atTrace().log(Supplier<String>)
- Replace JUL
Logger.finest(Supplier<String>)
with SLF4J'sLogger.atTrace().log(Supplier<String>)
- Replace JUL
Logger.getLogger(Some.class.getCanonicalName())
with SLF4J'sLoggerFactory.getLogger(Some.class)
- Replace JUL
Logger.getLogger(Some.class.getName())
with SLF4J'sLoggerFactory.getLogger(Some.class)
- Replace JUL
Logger.info(Supplier<String>)
with SLF4J'sLogger.atInfo().log(Supplier<String>)
- Replace JUL
Logger.isLoggable(Level.ALL)
with SLF4J'sLogger.isTraceEnabled
- Replace JUL
Logger.isLoggable(Level.CONFIG)
with SLF4J'sLogger.isInfoEnabled()
- Replace JUL
Logger.isLoggable(Level.FINE)
with SLF4J'sLogger.isDebugEnabled()
- Replace JUL
Logger.isLoggable(Level.FINER)
with SLF4J'sLogger.isTraceEnabled()
- Replace JUL
Logger.isLoggable(Level.FINEST)
with SLF4J'sLogger.isTraceEnabled
- Replace JUL
Logger.isLoggable(Level.INFO)
with SLF4J'sLogger.isInfoEnabled()
- Replace JUL
Logger.isLoggable(Level.SEVERE)
with SLF4J'sLogger.isErrorEnabled()
- Replace JUL
Logger.isLoggable(Level.WARNING)
with SLF4J'sLogger.isWarnEnabled()
- Replace JUL
Logger.log(Level.ALL, Supplier<String>)
with SLF4J'sLogger.atInfo().log(Supplier<String>)
- Replace JUL
Logger.log(Level.CONFIG, Supplier<String>)
with SLF4J'sLogger.atInfo().log(Supplier<String>)
- Replace JUL
Logger.log(Level.FINE, Supplier<String>)
with SLF4J'sLogger.atInfo().log(Supplier<String>)
- Replace JUL
Logger.log(Level.FINER, Supplier<String>)
with SLF4J'sLogger.atInfo().log(Supplier<String>)
- Replace JUL
Logger.log(Level.FINEST, Supplier<String>)
with SLF4J'sLogger.atInfo().log(Supplier<String>)
- Replace JUL
Logger.log(Level.INFO, Supplier<String>)
with SLF4J'sLogger.atInfo().log(Supplier<String>)
- Replace JUL
Logger.log(Level.SEVERE, Supplier<String>)
with SLF4J'sLogger.atInfo().log(Supplier<String>)
- Replace JUL
Logger.log(Level.WARNING, Supplier<String>)
with SLF4J'sLogger.atInfo().log(Supplier<String>)
- Replace JUL
Logger.severe(Supplier<String>)
with SLF4J'sLogger.atError().log(Supplier<String>)
- Replace JUL
Logger.warning(Supplier<String>)
with SLF4J'sLogger.atWarn().log(Supplier<String>)
- Replace JUL
logger.log(Level.ALL, String message, Throwable e)
with SLF4J'sLogger.trace(message, e)
- Replace JUL
logger.log(Level.ALL, e, Supplier<String>)
with SLF4J'sLogger.atTrace().log(Supplier<String>)
- Replace JUL
logger.log(Level.CONFIG, String message, Throwable e)
with SLF4J'sLogger.info(message, e)
- Replace JUL
logger.log(Level.CONFIG, e, Supplier<String>)
with SLF4J'sLogger.atInfo().log(Supplier<String>)
- Replace JUL
logger.log(Level.FINE, String message, Throwable e)
with SLF4J'sLogger.debug(message, e)
- Replace JUL
logger.log(Level.FINE, e, Supplier<String>)
with SLF4J'sLogger.atDebug().log(Supplier<String>)
- Replace JUL
logger.log(Level.FINER, String message, Throwable e)
with SLF4J'sLogger.trace(message, e)
- Replace JUL
logger.log(Level.FINER, e, Supplier<String>)
with SLF4J'sLogger.atTrace().log(Supplier<String>)
- Replace JUL
logger.log(Level.FINEST, String message, Throwable e)
with SLF4J'sLogger.trace(message, e)
- Replace JUL
logger.log(Level.FINEST, e, Supplier<String>)
with SLF4J'sLogger.atTrace().log(Supplier<String>)
- Replace JUL
logger.log(Level.INFO, String message, Throwable e)
with SLF4J'sLogger.info(message, e)
- Replace JUL
logger.log(Level.INFO, e, Supplier<String>)
with SLF4J'sLogger.atInfo().log(Supplier<String>)
- Replace JUL
logger.log(Level.SEVERE, String message, Throwable e)
with SLF4J'sLogger.error(message, e)
- Replace JUL
logger.log(Level.SEVERE, e, Supplier<String>)
with SLF4J'sLogger.atError().log(Supplier<String>)
- Replace JUL
logger.log(Level.WARNING, String message, Throwable e)
with SLF4J'sLogger.warn(message, e)
- Replace JUL
logger.log(Level.WARNING, e, Supplier<String>)
with SLF4J'sLogger.atWarn().log(Supplier<String>)
- Replace parameterized JUL level call with corresponding SLF4J method calls
- SLF4J logging statements should begin with constants