org.apache.log4j.extras

## Class DOMConfigurator

- java.lang.Object
- - org.apache.log4j.extras.DOMConfigurator

- All Implemented Interfaces:
    org.apache.log4j.spi.Configurator

      public class DOMConfigurator
      extends Object
      implements org.apache.log4j.spi.Configurator

  This is a duplicate (with minor modifications) of the log4j 1.2.15 DOMConfigurator renamed for use with earlier versions of log4j.

- - ### Field Summary

    - ### Fields inherited from interface org.apache.log4j.spi.Configurator

      `INHERITED, NULL`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `DOMConfigurator()` No argument constructor.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `static void` | `configure(Element element)` Configure log4j using a `configuration` element as defined in the log4j.dtd.
    `static void` | `configure(String filename)` A static version of `doConfigure(String, LoggerRepository)`.
    `static void` | `configure(URL url)` A static version of `doConfigure(URL, LoggerRepository)`.
    `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(Element element, org.apache.log4j.spi.LoggerRepository repository)` Configure by taking in an DOM element.
    `protected void` | `doConfigure(InputSource inputSource, org.apache.log4j.spi.LoggerRepository repository)` Configure log4j by reading in a log4j.dtd compliant XML configuration file.
    `void` | `doConfigure(InputStream inputStream, org.apache.log4j.spi.LoggerRepository repository)` Configure log4j by reading in a log4j.dtd compliant XML configuration file.
    `void` | `doConfigure(Reader reader, org.apache.log4j.spi.LoggerRepository repository)` Configure log4j by reading in a log4j.dtd compliant XML configuration file.
    `void` | `doConfigure(String filename, org.apache.log4j.spi.LoggerRepository repository)`
    `void` | `doConfigure(URL url, org.apache.log4j.spi.LoggerRepository repository)`
    `protected org.apache.log4j.Appender` | `findAppenderByName(Document doc, String appenderName)` Used internally to parse appenders by IDREF name.
    `protected org.apache.log4j.Appender` | `findAppenderByReference(Element appenderRef)` Used internally to parse appenders by IDREF element.
    `protected void` | `parse(Element element)` Used internally to configure the log4j framework by parsing a DOM tree of XML elements based on log4j.dtd.
    `protected org.apache.log4j.Appender` | `parseAppender(Element appenderElement)` Used internally to parse an appender element.
    `protected void` | `parseCategory(Element loggerElement)` Used internally to parse an category element.
    `protected void` | `parseCategoryFactory(Element factoryElement)` Used internally to parse the category factory element.
    `protected void` | `parseChildrenOfLoggerElement(Element catElement, org.apache.log4j.Logger cat, boolean isRoot)` Used internally to parse the children of a category element.
    `static org.apache.log4j.spi.OptionHandler` | `parseElement(Element element, Properties props, Class expectedClass)` Creates an OptionHandler and processes any nested param elements but does not call activateOptions.
    `protected void` | `parseErrorHandler(Element element, org.apache.log4j.Appender appender)` Used internally to parse an `ErrorHandler` element.
    `protected void` | `parseFilters(Element element, org.apache.log4j.Appender appender)` Used internally to parse a filter element.
    `protected org.apache.log4j.Layout` | `parseLayout(Element layout_element)` Used internally to parse a layout element.
    `protected void` | `parseLevel(Element element, org.apache.log4j.Logger logger, boolean isRoot)` Used internally to parse a level element.
    `protected void` | `parseRenderer(Element element)`
    `protected void` | `parseRoot(Element rootElement)` Used internally to parse the roor category element.
    `protected void` | `setParameter(Element elem, org.apache.log4j.config.PropertySetter propSetter)`
    `static void` | `setParameter(Element elem, org.apache.log4j.config.PropertySetter propSetter, Properties props)` Sets a parameter based from configuration file content.
    `protected String` | `subst(String value)`
    `static String` | `subst(String value, Properties props)` Substitutes property value for any references in expression.

    - ### 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

    - #### findAppenderByName

          protected org.apache.log4j.Appender findAppenderByName(Document doc,
                                                     String appenderName)

      Used internally to parse appenders by IDREF name.

    - #### findAppenderByReference

          protected org.apache.log4j.Appender findAppenderByReference(Element appenderRef)

      Used internally to parse appenders by IDREF element.

    - #### parseAppender

          protected org.apache.log4j.Appender parseAppender(Element appenderElement)

      Used internally to parse an appender element.

    - #### parseErrorHandler

          protected void parseErrorHandler(Element element,
                               org.apache.log4j.Appender appender)

      Used internally to parse an `ErrorHandler` element.

    - #### parseFilters

          protected void parseFilters(Element element,
                          org.apache.log4j.Appender appender)

      Used internally to parse a filter element.

    - #### parseCategory

          protected void parseCategory(Element loggerElement)

      Used internally to parse an category element.

    - #### parseCategoryFactory

          protected void parseCategoryFactory(Element factoryElement)

      Used internally to parse the category factory element.

    - #### parseRoot

          protected void parseRoot(Element rootElement)

      Used internally to parse the roor category element.

    - #### parseChildrenOfLoggerElement

          protected void parseChildrenOfLoggerElement(Element catElement,
                                          org.apache.log4j.Logger cat,
                                          boolean isRoot)

      Used internally to parse the children of a category element.

    - #### parseLayout

          protected org.apache.log4j.Layout parseLayout(Element layout_element)

      Used internally to parse a layout element.

    - #### parseRenderer

          protected void parseRenderer(Element element)

    - #### parseLevel

          protected void parseLevel(Element element,
                        org.apache.log4j.Logger logger,
                        boolean isRoot)

      Used internally to parse a level element.

    - #### setParameter

          protected void setParameter(Element elem,
                          org.apache.log4j.config.PropertySetter propSetter)

    - #### configure

          public static void configure(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,
                         org.apache.log4j.spi.LoggerRepository repository)

    - #### doConfigure

          public void doConfigure(URL url,
                         org.apache.log4j.spi.LoggerRepository repository)

      Specified by:
        `doConfigure` in interface `org.apache.log4j.spi.Configurator`

    - #### doConfigure

          public void doConfigure(InputStream inputStream,
                         org.apache.log4j.spi.LoggerRepository repository)
                           throws FactoryConfigurationError

      Configure log4j by reading in a log4j.dtd compliant XML configuration file.
      Specified by:
        `doConfigure` in interface `org.apache.log4j.spi.Configurator`
      Throws:
        `FactoryConfigurationError`

    - #### doConfigure

          public void doConfigure(Reader reader,
                         org.apache.log4j.spi.LoggerRepository repository)
                           throws FactoryConfigurationError

      Configure log4j by reading in a log4j.dtd compliant XML configuration file.
      Throws:
        `FactoryConfigurationError`

    - #### doConfigure

          protected void doConfigure(InputSource inputSource,
                         org.apache.log4j.spi.LoggerRepository repository)
                              throws FactoryConfigurationError

      Configure log4j by reading in a log4j.dtd compliant XML configuration file.
      Throws:
        `FactoryConfigurationError`

    - #### doConfigure

          public void doConfigure(Element element,
                         org.apache.log4j.spi.LoggerRepository repository)

      Configure by taking in an DOM element.

    - #### configure

          public static void configure(String filename)
                                throws FactoryConfigurationError

      A static version of `doConfigure(String, LoggerRepository)`.
      Throws:
        `FactoryConfigurationError`

    - #### configure

          public static void configure(URL url)
                                throws FactoryConfigurationError

      A static version of `doConfigure(URL, LoggerRepository)`.
      Throws:
        `FactoryConfigurationError`

    - #### parse

          protected void parse(Element element)

      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)

    - #### subst

          public static String subst(String value,
                     Properties props)

      Substitutes property value for any references in expression.
      Parameters:
        `value` - value from configuration file, may contain literal text, property references or both
        `props` - properties.
      Returns:
        evaluated expression, may still contain expressions if unable to expand.
      Since:
        1.2.15

    - #### setParameter

          public static void setParameter(Element elem,
                          org.apache.log4j.config.PropertySetter propSetter,
                          Properties props)

      Sets a parameter based from configuration file content.
      Parameters:
        `elem` - param element, may not be null.
        `propSetter` - property setter, may not be null.
        `props` - properties
      Since:
        1.2.15

    - #### parseElement

          public static org.apache.log4j.spi.OptionHandler parseElement(Element element,
                                                        Properties props,
                                                        Class expectedClass)
                                                                 throws Exception

      Creates an OptionHandler and processes any nested param elements but does not call activateOptions. If the class also supports UnrecognizedElementParser, the parseUnrecognizedElement method will be call for any child elements other than param.
      Parameters:
        `element` - element, may not be null.
        `props` - properties
        `expectedClass` - interface or class expected to be implemented by created class
      Returns:
        created class or null.
      Throws:
        `Exception` - thrown if the contain object should be abandoned.
      Since:
        1.2.15

Copyright © 2013 The Apache Software Foundation. Licensed under the Apache License, Version 2.0

Apache Extras for Apache log4j, Apache log4j and Apache are trademarks of the Apache Software Foundation.