Java slf4j Logger isLoggable(final Logger logger, final Level level)

Here you can find the source of isLoggable(final Logger logger, final Level level)

Description

Is the desired LogLevel active?

License

Open Source License

Parameter

Parameter Description
logger the logger to be checked
level the log- Level to be checked

Return

true if it is logable

Declaration

public static boolean isLoggable(final Logger logger, final Level level) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.util.logging.Level;
import org.slf4j.Logger;

public class Main {
    /**//from www  .  ja v a 2  s .c o  m
     * Is the desired LogLevel active?
     * 
     * @param logger the logger to be checked
     * @param level the log-{@link Level} to be checked
     * @return true if it is logable
     */
    public static boolean isLoggable(final Logger logger, final Level level) {
        if (level == Level.INFO) {
            return logger.isInfoEnabled();
        } else if (level == Level.SEVERE) {
            return logger.isErrorEnabled();
        } else if (level == Level.WARNING) {
            return logger.isWarnEnabled();
        } else if (level == Level.FINE || level == Level.FINER || level == Level.FINEST) {
            return logger.isDebugEnabled();
        }
        return false;
    }
}

Related

  1. info(Logger logger, String msg, Object... params)
  2. info(String format, Object... arguments)
  3. infoLogging(Logger log, String logMessage, Object[] obj)
  4. infoTimeTaken(final Logger log, final long startTime, final long numItems, final String message, final Object... args)
  5. interruptCurrentThreadWithLog(Logger logger)
  6. isSlf4jPresent()
  7. log(Logger logger, int logLevel, String value)
  8. log(Logger logger, Throwable t)
  9. log(String format, Object... arguments)