FileDocCategorySizeDatePackage
CustomizedLogLevels.javaAPI DocApache log4j 1.2.154678Sat Aug 25 00:09:44 BST 2007examples.lf5.UsingLogMonitorAdapter

CustomizedLogLevels

public class CustomizedLogLevels extends Object
This class is a simple example of how use the LogMonitorAdapter to bypass the Log4JAppender and post LogRecords directly to the LogMonitor using customized LogLevels To make this example work, ensure that the lf5.jar and lf5-license.jar files are in your classpath, and then run the example at the command line.
author
Richard Hurst

Fields Summary
public static final LogLevel
LEVEL_ONE
public static final LogLevel
LEVEL_TWO
public static final LogLevel
LEVEL_THREE
public static final LogLevel
LEVEL_FOUR
public static final LogLevel
DEFAULT
private static LogMonitorAdapter
_adapter
Constructors Summary
Methods Summary
public voiddoMyBidding()

        // tell the LogMonitorAdapter which LogLevel is the severe Level if necessary
        _adapter.setSevereLevel(LEVEL_ONE);

        String levels = this.getClass().getName();

        // will used the default Level
        _adapter.log(levels, "Using the customized LogLevels");

        _adapter.log(levels, LEVEL_FOUR, "This is a test");
        _adapter.log(levels, LEVEL_THREE, "Hmmm fobidden doughnut");
        _adapter.log(levels, LEVEL_ONE, "Danger Danger Will Robinson",
                new RuntimeException("DANGER"), "32");
        _adapter.log(levels, LEVEL_TWO, "Exit stage right->");
        _adapter.log(levels, LEVEL_FOUR, "What's up Doc?",
                new NullPointerException("Unfortunate exception"));

    
public static voidmain(java.lang.String[] args)


     
        // The first LogLevel in the Array will be used as the default LogLevel.
        _adapter = LogMonitorAdapter.newInstance(new LogLevel[]{DEFAULT, LEVEL_ONE,
                                                                LEVEL_TWO, LEVEL_THREE, LEVEL_FOUR, LogLevel.FATAL});
        // if a different log level is to be used it can be specified as such
        // _adapter.setDefaultLevel(LEVEL_THREE);
    
        CustomizedLogLevels test = new CustomizedLogLevels();
        test.doMyBidding();