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

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

Introduction

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

Prototype

public void debug(Object message) 

Source Link

Document

Log a message to the Log4j Logger with DEBUG priority.

Usage

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

/**
 * DOCUMENT ME!// w  w  w.  j  av a2s. com
 * 
 * @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);

}