FileDocCategorySizeDatePackage
XMLSample.javaAPI DocApache log4j 1.2.152058Sat Aug 25 00:09:42 BST 2007org.apache.log4j.xml.examples

XMLSample

public class XMLSample extends Object
This example code shows how to read an XML based configuration file using a DOM parser.

Sample XML files sample1.xml and sample2.xml are provided.

Note that the log4j.dtd is not in the local directory. It is found by the class loader.

author
Ceki Gülcü

Fields Summary
static Logger
cat
Constructors Summary
Methods Summary
static voidUsage(java.lang.String msg)

    System.err.println(msg);
    System.err.println( "Usage: java " + XMLSample.class.getName() +
			"configFile");
    System.exit(1);
  
static voidinit(java.lang.String configFile)

    DOMConfigurator.configure(configFile);
  
public static voidmain(java.lang.String[] argv)


  
  
     

    if(argv.length == 1)
      init(argv[0]);
    else
      Usage("Wrong number of arguments.");
    sample();
  
static voidsample()

    int i = -1;
    cat.debug("Message " + ++i);
    cat.warn ("Message " + ++i);
    cat.error("Message " + ++i);
    Exception e = new Exception("Just testing");
    cat.debug("Message " + ++i, e);