Package org.apache.log4j.extras
Class DOMConfigurator
java.lang.Object
org.apache.log4j.extras.DOMConfigurator
- All Implemented Interfaces:
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.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static final class
AnEntityResolver
specifically designed to returnlog4j.dtd
which is embedded within the log4j jar file.private static interface
private static class
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) static final String
(package private) static final String
(package private) static final String
private Hashtable
(package private) static final String
(package private) static final String
private org.apache.log4j.spi.LoggerFactory
(package private) static final String
(package private) static final String
(package private) static final String
(package private) static final String
(package private) static final String
(package private) static final String
(package private) static final String
(package private) static final String
(package private) static final String
(package private) static final String
(package private) static final String
(package private) static final String
(package private) static final String
(package private) static final String
(package private) static final String
(package private) static final Class[]
(package private) static final String
(package private) static final String
private Properties
(package private) static final String
(package private) static final String
(package private) static final String
(package private) static final String
private org.apache.log4j.spi.LoggerRepository
private static final String
(package private) static final String
(package private) static final String
(package private) static final String
(package private) static final String
Fields inherited from interface org.apache.log4j.spi.Configurator
INHERITED, NULL
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic void
A static version ofdoConfigure(String, LoggerRepository)
.static void
A static version ofdoConfigure(URL, LoggerRepository)
.static void
Configure log4j using aconfiguration
element as defined in the log4j.dtd.static void
configureAndWatch
(String configFilename) LikeconfigureAndWatch(String, long)
except that the default delay as defined byFileWatchdog.DEFAULT_DELAY
is used.static void
configureAndWatch
(String configFilename, long delay) Read the configuration fileconfigFilename
if it exists.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) private final void
doConfigure
(DOMConfigurator.ParseAction action, org.apache.log4j.spi.LoggerRepository repository) 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.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
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 anErrorHandler
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
Used internally to parse the roor category element.private static void
parseUnrecognizedElement
(Object instance, Element element, Properties props) Delegates unrecognized content to created instance if it supports UnrecognizedElementParser.private static void
quietParseUnrecognizedElement
(Object instance, Element element, Properties props) Delegates unrecognized content to created instance if it supports UnrecognizedElementParser and catches and logs any exception.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
static String
subst
(String value, Properties props) Substitutes property value for any references in expression.
-
Field Details
-
CONFIGURATION_TAG
- See Also:
-
OLD_CONFIGURATION_TAG
- See Also:
-
RENDERER_TAG
- See Also:
-
APPENDER_TAG
- See Also:
-
APPENDER_REF_TAG
- See Also:
-
PARAM_TAG
- See Also:
-
LAYOUT_TAG
- See Also:
-
CATEGORY
- See Also:
-
LOGGER
- See Also:
-
LOGGER_REF
- See Also:
-
CATEGORY_FACTORY_TAG
- See Also:
-
LOGGER_FACTORY_TAG
- See Also:
-
NAME_ATTR
- See Also:
-
CLASS_ATTR
- See Also:
-
VALUE_ATTR
- See Also:
-
ROOT_TAG
- See Also:
-
ROOT_REF
- See Also:
-
LEVEL_TAG
- See Also:
-
PRIORITY_TAG
- See Also:
-
FILTER_TAG
- See Also:
-
ERROR_HANDLER_TAG
- See Also:
-
REF_ATTR
- See Also:
-
ADDITIVITY_ATTR
- See Also:
-
THRESHOLD_ATTR
- See Also:
-
CONFIG_DEBUG_ATTR
- See Also:
-
INTERNAL_DEBUG_ATTR
- See Also:
-
RESET_ATTR
- See Also:
-
RENDERING_CLASS_ATTR
- See Also:
-
RENDERED_CLASS_ATTR
- See Also:
-
EMPTY_STR
- See Also:
-
ONE_STRING_PARAM
-
dbfKey
- See Also:
-
appenderBag
-
props
-
repository
private org.apache.log4j.spi.LoggerRepository repository -
catFactory
private org.apache.log4j.spi.LoggerFactory catFactory
-
-
Constructor Details
-
DOMConfigurator
public DOMConfigurator()No argument constructor.
-
-
Method Details
-
findAppenderByName
Used internally to parse appenders by IDREF name. -
findAppenderByReference
Used internally to parse appenders by IDREF element. -
parseUnrecognizedElement
private static void parseUnrecognizedElement(Object instance, Element element, Properties props) throws Exception Delegates unrecognized content to created instance if it supports UnrecognizedElementParser.- Parameters:
instance
- instance, may be null.element
- element, may not be null.props
- properties- Throws:
IOException
- thrown if configuration of owner object should be abandoned.Exception
- Since:
- 1.2.15
-
quietParseUnrecognizedElement
private static void quietParseUnrecognizedElement(Object instance, Element element, Properties props) Delegates unrecognized content to created instance if it supports UnrecognizedElementParser and catches and logs any exception.- Parameters:
instance
- instance, may be null.element
- element, may not be null.props
- properties- Since:
- 1.2.15
-
parseAppender
Used internally to parse an appender element. -
parseErrorHandler
Used internally to parse anErrorHandler
element. -
parseFilters
Used internally to parse a filter element. -
parseCategory
Used internally to parse an category element. -
parseCategoryFactory
Used internally to parse the category factory element. -
parseRoot
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
Used internally to parse a layout element. -
parseRenderer
-
parseLevel
Used internally to parse a level element. -
setParameter
-
configure
Configure log4j using aconfiguration
element as defined in the log4j.dtd. -
configureAndWatch
LikeconfigureAndWatch(String, long)
except that the default delay as defined byFileWatchdog.DEFAULT_DELAY
is used.- Parameters:
configFilename
- A log4j configuration file in XML format.
-
configureAndWatch
Read the configuration fileconfigFilename
if it exists. Moreover, a thread will be created that will periodically check ifconfigFilename
has been created or modified. The period is determined by thedelay
argument. If a change or file creation is detected, thenconfigFilename
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
-
doConfigure
- Specified by:
doConfigure
in interfaceorg.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 interfaceorg.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
private final void doConfigure(DOMConfigurator.ParseAction action, org.apache.log4j.spi.LoggerRepository repository) throws FactoryConfigurationError - Throws:
FactoryConfigurationError
-
doConfigure
Configure by taking in an DOM element. -
configure
A static version ofdoConfigure(String, LoggerRepository)
.- Throws:
FactoryConfigurationError
-
configure
A static version ofdoConfigure(URL, LoggerRepository)
.- Throws:
FactoryConfigurationError
-
parse
Used internally to configure the log4j framework by parsing a DOM tree of XML elements based on log4j.dtd. -
subst
-
subst
Substitutes property value for any references in expression.- Parameters:
value
- value from configuration file, may contain literal text, property references or bothprops
- 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
- propertiesexpectedClass
- 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
-