Example usage for org.apache.commons.logging Log isDebugEnabled

List of usage examples for org.apache.commons.logging Log isDebugEnabled

Introduction

In this page you can find the example usage for org.apache.commons.logging Log isDebugEnabled.

Prototype

boolean isDebugEnabled();

Source Link

Document

Is debug logging currently enabled?

Usage

From source file:LoggingTrial.java

public static void main(String[] args) {
    Log log = LogFactory.getLog(LoggingTrial.class);
    System.out.println("The Log being used >>> " + log);

    Exception e = new Exception("A DUMMY EXCEPTION");
    if (log.isTraceEnabled()) {
        log.trace("TRACE TEST");
        log.trace("TRACE TEST", e);
    }/*from   w  w  w .  java  2 s  .  co  m*/
    if (log.isDebugEnabled()) {
        log.debug("DEBUG TEST");
        log.debug("DEBUG TEST", e);
    }

    if (log.isInfoEnabled()) {
        log.info("INFO TEST");
        log.info("INFO TEST", e);
    }
    if (log.isWarnEnabled()) {
        log.warn("WARN TEST");
        log.warn("WARN TEST", e);
    }

    if (log.isErrorEnabled()) {
        log.error("ERROR TEST");
        log.error("ERROR TEST", e);
    }

    if (log.isFatalEnabled()) {
        log.fatal("FATAL TEST");
        log.fatal("FATAL TEST", e);
    }
}

From source file:com.moss.veracity.core.Veracity.java

public static void main(String[] args) throws Exception {

    File log4jConfigFile = new File("log4j.xml");

    if (log4jConfigFile.exists()) {
        DOMConfigurator.configureAndWatch(log4jConfigFile.getAbsolutePath(), 1000);
    }/*from   w  ww  . j  a  v a  2 s.  com*/

    final Log log = LogFactory.getLog(Veracity.class);

    File homeDir = new File(System.getProperty("user.home"));
    File currentDir = new File(System.getProperty("user.dir"));

    List<File> configLocations = new LinkedList<File>();
    configLocations.addAll(Arrays.asList(new File[] { new File("/etc/veracity.config"),
            new File(homeDir, ".veracity.config"), new File(currentDir, "config.xml") }));

    String customConfigFileProperty = System.getProperty("veracity.configFile");
    if (customConfigFileProperty != null) {
        configLocations.clear();
        configLocations.add(new File(customConfigFileProperty));
    }

    File configFile = null;

    Iterator<File> i = configLocations.iterator();
    while ((configFile == null || !configFile.exists()) && i.hasNext()) {
        configFile = i.next();
    }

    LaunchParameters parameters;

    if (!configFile.exists()) {
        if (log.isDebugEnabled()) {
            log.debug("Creating default config file at " + configFile.getAbsolutePath());
        }
        parameters = new LaunchParameters();
        parameters.save(configFile);
    } else {
        if (log.isDebugEnabled()) {
            log.debug("Loading parameters from config file at " + configFile.getAbsolutePath());
        }
        parameters = LaunchParameters.load(configFile);
    }

    parameters.readSystemProperties();

    new Veracity(parameters);
}

From source file:edu.umich.robot.util.Configs.java

public static void toLog(Log logger, Config config) {
    if (!logger.isDebugEnabled())
        return;/* w w w .  j  a  v a2  s . c o  m*/

    List<String> keys = new LinkedList<String>();
    Collections.addAll(keys, config.getKeys());
    Collections.sort(keys);
    for (String key : keys)
        logger.debug(String.format("%s = %s", key, Arrays.toString(config.getStrings(key))));
}

From source file:com.adaptris.security.util.SecurityUtil.java

/**
 * Print out all the algorithms provided by each provider to the specified
 * logger.//from  w  w  w.j a v a2 s  .  com
 *
 * @param logR the Log to be used for this output.
 */
public static void printAlgorithms(Log logR) {
    if (logR.isDebugEnabled() && Constants.DEBUG) {
        logR.debug(getAlgorithms());
    }
}

From source file:kr.co.aim.nanoframe.orm.SQLLogUtil.java

public static void logBeforeExecuting(String sql, Log log) {
    if (log.isDebugEnabled())
        log.debug("SQL [" + sql + "]");
}

From source file:kr.co.aim.nanoframe.orm.SQLLogUtil.java

public static void logAfterUpdate(int result, Log log) {
    if (log.isDebugEnabled())
        log.debug("SQL update affected " + result + " rows");
}

From source file:com.stimulus.archiva.exception.ChainedException.java

public static Level getLoggingLevel(Log logger) {
    if (logger.isDebugEnabled())
        return Level.DEBUG;
    else if (logger.isInfoEnabled())
        return Level.INFO;
    else if (logger.isWarnEnabled())
        return Level.WARN;
    else if (logger.isErrorEnabled())
        return Level.ERROR;
    else if (logger.isFatalEnabled())
        return Level.FATAL;

    return Level.DEBUG;
}

From source file:kr.co.aim.nanoframe.orm.SQLLogUtil.java

public static void logAfterQuery(Object result, Log log) {
    if (log.isDebugEnabled()) {
        if (result instanceof List)
            log.debug("SQL query returned " + ((List) result).size() + " rows");
        else if (result instanceof DataInfo)
            log.debug("SQL query returned 1 rows");
        else//from ww w  . j av a 2s.  c o  m
            log.debug("SQL query returned " + (Integer) result);
    }
}

From source file:com.headissue.pigeon.util.LogUtils.java

public static void debug(Log log, String message, Object... args) {
    if (log.isDebugEnabled()) {
        if (args != null && args.length > 0) {
            message = String.format(message, args);
        }/*from  w w w . j  a va  2 s.c  om*/
        log.debug(message);
    }
}

From source file:com.amazonaws.client.util.sdk.IOUtils.java

/**
 * Closes the given Closeable quietly.//from   www  . j  a  v a 2s .  c  om
 * @param is the given closeable
 * @param log logger used to log any failure should the close fail
 */
public static void closeQuietly(Closeable is, Log log) {
    if (is != null) {
        try {
            is.close();
        } catch (IOException ex) {
            Log logger = log == null ? defaultLog : log;
            if (logger.isDebugEnabled())
                logger.debug("Ignore failure in closing the Closeable", ex);
        }
    }
}