Java Utililty Methods slf4j Logger

List of utility methods to do slf4j Logger

Description

The list of methods to do slf4j Logger are organized into topic(s).

Method

LoggergetLogger(String className)
get Logger
return LoggerFactory.getLogger(className);
LoggergetLoggerForCurrentClass()
Create a slf4j logger based on the caller's class name.
Thread currThread = Thread.currentThread();
StackTraceElement[] trace = currThread.getStackTrace();
return LoggerFactory.getLogger(trace[2].getClassName());
LoggergetLoggerInstance(String callerCLass)
Returns a new Logger instance for given class name.
If logger instance already exist in cache returns existing one
if (LOGGER_INSTANCES.containsKey(callerCLass)) {
    return LOGGER_INSTANCES.get(callerCLass);
Logger logger = LoggerFactory.getLogger(callerCLass);
isTraceEnabled = logger.isTraceEnabled();
isDebugEnabled = logger.isDebugEnabled();
isInfoEnabled = logger.isInfoEnabled();
isWarnEnabled = logger.isWarnEnabled();
...
intgetLoggerLevel(Logger logger)
get Logger Level
if (logger == null) {
    throw new NullPointerException("logger must not be null");
if (logger.isTraceEnabled()) {
    return TRACE_LEVEL;
if (logger.isDebugEnabled()) {
    return DEBUG_LEVEL;
...
longgetLong(Properties config, String key, long defaultValue)
Get long from properties.
String val = config.getProperty(key);
if (val == null) {
    return defaultValue;
} else {
    try {
        return Long.parseLong(val);
    } catch (NumberFormatException nfe) {
        throw new IllegalArgumentException(
...
StringgetMessage(String message, Object... args)
get Message
return MessageFormatter.arrayFormat(message, args).getMessage();
intgetTraceLevel(Logger logger)
get Trace Level
if (logger.isDebugEnabled()) {
    return TRACE_DEBUG;
} else if (logger.isInfoEnabled()) {
    return TRACE_INFO;
} else if (logger.isWarnEnabled()) {
    return TRACE_WARN;
} else {
    return TRACE_ERROR;
...
voidic static void i(String fmt, Object... args)
i
i(logger, fmt, args);
voidinfo(Class clz, String logStr)
Log a message at the INFO level.
LoggerFactory.getLogger(clz).info("[" + clz.getSimpleName() + "] " + logStr);
voidinfo(final Logger log, final String message, final Object... args)
info
log.info(getFormattedMessage(message, args));