FileDocCategorySizeDatePackage
InitUsingDefaultConfigurator.javaAPI DocApache log4j 1.2.155024Sat Aug 25 00:09:44 BST 2007examples.lf5.InitUsingDefaultConfigurator

InitUsingDefaultConfigurator

public class InitUsingDefaultConfigurator extends Object
This class is a simple example of how to configure the LogFactor5 logging window using the DefaultLF5Configurator. The DefaultLF5Configurator uses a default configuration file stored in the log4j.jar in order to provide a default configuration for the LF5Appender.
author
Brent Sprecher

Fields Summary
private static Logger
logger
Constructors Summary
Methods Summary
public static voidfoo()

        logger.debug("Entered foo in InitUsingDefaultConfigurator class");

        NDC.push("#123456");
        logger.debug("Hello, my name is Marge Simpson.");
        logger.info("D'oh!! A deer! A female deer.");
        // Clean up NDC
        NDC.pop();
        NDC.remove();
    
public static voidmain(java.lang.String[] args)


    //--------------------------------------------------------------------------
    //   Constructors:
    //--------------------------------------------------------------------------

    //--------------------------------------------------------------------------
    //   Public Methods:
    //--------------------------------------------------------------------------

           
        // Configure the LF5Appender using the DefaultLF5Configurator.  This
        // will add the LF5Appender to the root of the Category tree.
        DefaultLF5Configurator.configure();

        // Add an NDC to demonstrate how NDC information is output.
        NDC.push("#23856");
        // Log some information.
        for (int i = 0; i < 10; i++) {
            logger.debug("Hello, my name is Homer Simpson.");
            logger.info("Mmmmmm .... Chocolate.");
            logger.warn("Mmm...forbidden donut.");
        }
        // Clean up NDC
        NDC.pop();
        NDC.remove();

        NDC.push("Another NDC");
        // Log some information.
        logger.fatal("Hello, my name is Bart Simpson.");
        logger.error("Hi diddly ho good neighbour.");
        // Clean up NDC
        NDC.pop();
        NDC.remove();

        // Call methods on both classes.
        InitUsingDefaultConfigurator.foo();
        InnerInitUsingDefaultConfigurator.foo();

        logger.info("Exiting InitUsingDefaultConfigurator.");