Log4j 1.1b7

org.apache.log4j.xml
Class DOMConfigurator

java.lang.Object
  |
  +--org.apache.log4j.BasicConfigurator
        |
        +--org.apache.log4j.xml.DOMConfigurator
All Implemented Interfaces:
Configurator

public class DOMConfigurator
extends BasicConfigurator
implements Configurator

Use this class to initialize the log4j environment using a DOM tree.

The DTD is specified in log4j.dtd.

Sometimes it is useful to see how log4j is reading configuration files. You can enable log4j internal logging by defining the log4j.configDebug variable on the java command line.

There are sample XML files included in the package.

Since:
0.8.3
Author:
Christopher Taylor, Ceki Gülcü, Anders Kristensen

Fields inherited from class org.apache.log4j.BasicConfigurator
DISABLE_KEY, DISABLE_OVERRIDE_KEY, INHERITED
 
Constructor Summary
DOMConfigurator()
          No argument constructor.
 
Method Summary
static void configure(org.w3c.dom.Element element)
          Configure log4j using a configuration element as defined in the log4j.dtd.
static void configure(String filename)
          This is the static version of doConfigure(String, Hierarchy).x
static void configureAndWatch(String configFilename)
          Like configureAndWatch(String, long) except that the default delay as defined by FileWatchdog.DEFAULT_DELAY is used.
static void configureAndWatch(String configFilename, long delay)
          Read the configuration file configFilename if it exists.
 void doConfigure(InputStream input, Hierarchy hierarchy)
          Configure log4j by reading in a log4j.dtd compliant XML configuration file.
 void doConfigure(String filename, Hierarchy hierarchy)
           
 void doConfigure(URL url, Hierarchy hierarchy)
          Interpret a resource pointed by a URL and set up log4j accordingly.
protected  Appender findAppenderByReference(org.w3c.dom.Element appenderRef)
          Used internally to parse appenders by IDREF.
protected  void parse(org.w3c.dom.Element element, Hierarchy hierarchy)
          Used internally to configure the log4j framework by parsing a DOM tree of XML elements based on log4j.dtd.
protected  Appender parseAppender(org.w3c.dom.Element appenderElement)
          Used internally to parse an appender element.
protected  void parseCategory(org.w3c.dom.Element categoryElement, Hierarchy hierarchy)
          Used internally to parse an category element.
protected  void parseChildrenOfCategoryElement(org.w3c.dom.Element catElement, Category cat, boolean isRoot)
          Used internally to parse the children of a category element.
protected  void parseErrorHandler(org.w3c.dom.Element element, Appender appender)
          Used internally to parse an ErrorHandler element.
protected  void parseFilters(org.w3c.dom.Element element, Appender appender)
          Used internally to parse a filter element.
protected  Layout parseLayout(org.w3c.dom.Element layout_element)
          Used internally to parse a layout element.
protected  void parsePriority(org.w3c.dom.Element element, Category cat, boolean isRoot)
          Used internally to parse a priority element.
protected  void parseRenderer(org.w3c.dom.Element element, Hierarchy hierarchy)
           
protected  void parseRoot(org.w3c.dom.Element rootElement, Hierarchy hierarchy)
          Used internally to parse the roor category element.
protected  void setParameter(org.w3c.dom.Element elem, PropertySetter propSetter)
           
protected  String subst(String value)
           
 
Methods inherited from class org.apache.log4j.BasicConfigurator
addRenderer, configure, configure, disable, disable, disableAll, disableDebug, disableInfo, enableAll, resetConfiguration, resetConfiguration
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DOMConfigurator

public DOMConfigurator()
No argument constructor.
Method Detail

findAppenderByReference

protected Appender findAppenderByReference(org.w3c.dom.Element appenderRef)
Used internally to parse appenders by IDREF.

parseAppender

protected Appender parseAppender(org.w3c.dom.Element appenderElement)
Used internally to parse an appender element.

parseErrorHandler

protected void parseErrorHandler(org.w3c.dom.Element element,
                                 Appender appender)
Used internally to parse an ErrorHandler element.

parseFilters

protected void parseFilters(org.w3c.dom.Element element,
                            Appender appender)
Used internally to parse a filter element.

parseCategory

protected void parseCategory(org.w3c.dom.Element categoryElement,
                             Hierarchy hierarchy)
Used internally to parse an category element.

parseRoot

protected void parseRoot(org.w3c.dom.Element rootElement,
                         Hierarchy hierarchy)
Used internally to parse the roor category element.

parseChildrenOfCategoryElement

protected void parseChildrenOfCategoryElement(org.w3c.dom.Element catElement,
                                              Category cat,
                                              boolean isRoot)
Used internally to parse the children of a category element.

parseLayout

protected Layout parseLayout(org.w3c.dom.Element layout_element)
Used internally to parse a layout element.

parseRenderer

protected void parseRenderer(org.w3c.dom.Element element,
                             Hierarchy hierarchy)

parsePriority

protected void parsePriority(org.w3c.dom.Element element,
                             Category cat,
                             boolean isRoot)
Used internally to parse a priority element.

setParameter

protected void setParameter(org.w3c.dom.Element elem,
                            PropertySetter propSetter)

configure

public static void configure(org.w3c.dom.Element element)
Configure log4j using a configuration element as defined in the log4j.dtd.

configureAndWatch

public static void configureAndWatch(String configFilename)
Like configureAndWatch(String, long) except that the default delay as defined by FileWatchdog.DEFAULT_DELAY is used.
Parameters:
configFilename - A log4j configuration file in XML format.

configureAndWatch

public static void configureAndWatch(String configFilename,
                                     long delay)
Read the configuration file configFilename if it exists. Moreover, a thread will be created that will periodically check if configFilename has been created or modified. The period is determined by the delay argument. If a change or file creation is detected, then configFilename is read to configure log4j.
Parameters:
configFilename - A log4j configuration file in XML format.
delay - The delay in milliseconds to wait between each check.

doConfigure

public void doConfigure(String filename,
                        Hierarchy hierarchy)

doConfigure

public void doConfigure(URL url,
                        Hierarchy hierarchy)
Description copied from interface: Configurator
Interpret a resource pointed by a URL and set up log4j accordingly. The configuration is done relative to the hierarchy parameter.
Specified by:
doConfigure in interface Configurator
Following copied from interface: org.apache.log4j.spi.Configurator
Parameters:
url - The URL to parse
hierarchy - The hierarchy to operation upon.

doConfigure

public void doConfigure(InputStream input,
                        Hierarchy hierarchy)
                 throws javax.xml.parsers.FactoryConfigurationError
Configure log4j by reading in a log4j.dtd compliant XML configuration file.

configure

public static void configure(String filename)
                      throws javax.xml.parsers.FactoryConfigurationError
This is the static version of doConfigure(String, Hierarchy).x

parse

protected void parse(org.w3c.dom.Element element,
                     Hierarchy hierarchy)
Used internally to configure the log4j framework by parsing a DOM tree of XML elements based on log4j.dtd.

subst

protected String subst(String value)

Log4j 1.1b7

Please notify me about new log4j releases.