Example usage for org.apache.commons.logging.impl Log4JLogger isDebugEnabled

List of usage examples for org.apache.commons.logging.impl Log4JLogger isDebugEnabled

Introduction

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

Prototype

public boolean isDebugEnabled() 

Source Link

Document

Check whether the Log4j Logger used is enabled for DEBUG priority.

Usage

From source file:com.nabla.project.application.core.log.LogCustomTest.java

/**
 * DOCUMENT ME!//from ww w  .j av  a 2s. c om
 * 
 * @throws Exception DOCUMENT ME!
 */
public void testLog() throws Exception {

    if (logger.isDebugEnabled()) {
        logger.debug("testLog");
    }

    ApplicationContext ctx = new FileSystemXmlApplicationContext(
            "src/test/java/com/nabla/project/application/core/log/LogCustom.xml");
    Log4JLogger commonlogger = (Log4JLogger) ctx.getBean("loggingfactorybean");

    if (commonlogger.isDebugEnabled()) {
        commonlogger.debug("Common logger is enable");
    }

    Log.setCommonlogger(commonlogger);

    if (Log.getCommonlogger().isDebugEnabled()) {
        Log.getCommonlogger().debug("mylogger 1 - DEBUG - should not be print");
    }

    if (logger.isDebugEnabled()) {
        logger.debug("rootLogger 1 - DEBUG - should not be print");
    }

    Log.getCommonlogger().warn("mylogger 3 - WARNING");
    logger.warn("rootLogger 1 - WARNING - should not be print");
    Log.getCommonlogger().info("mylogger 2 - INFO - should not be print");
    logger.info("rootLogger 1 - INFO - should not be print");
    Log.getCommonlogger().error("mylogger 4 - ERROR");
    logger.error("rootLogger 4 - ERROR - should not be print");
    Log.getCommonlogger().fatal("mylogger 5 - FATAL");
    logger.fatal("rootLogger 5 - FATAL");

    Thread.sleep(5000L);

}