public class DOMConfigurator extends Object
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.debug variable on the java command
line. Alternatively, set the debug
attribute in the
jdk:configuration
element. As in
<log4j:configuration debug="true" xmlns:log4j="http://jakarta.apache.org/log4j/"> ... </log4j:configuration>
There are sample XML files included in the package.
Constructor and Description |
---|
DOMConfigurator()
No argument constructor.
|
DOMConfigurator(ErrorManager errorLog) |
Modifier and Type | Method and Description |
---|---|
static void |
configure(Element element)
Configure jdk using a
configuration element as
defined in the jdk.dtd. |
static void |
configure(InputStream is)
A static version of
doConfigure(java.net.URL, LogManager) . |
static void |
configure(String filename)
A static version of
doConfigure(String, LogManager) . |
static void |
configure(URL url)
A static version of
doConfigure(java.net.URL, LogManager) . |
protected void |
debug(String msg) |
void |
doConfigure(Element element,
LogManager repository)
Configure by taking in an DOM element.
|
protected void |
doConfigure(InputSource inputSource,
LogManager repository)
Configure jdk by reading in a jdk.dtd compliant XML
configuration file.
|
void |
doConfigure(InputStream inputStream,
LogManager repository)
Configure jdk by reading in a jdk.dtd compliant XML
configuration file.
|
void |
doConfigure(Reader reader,
LogManager repository)
Configure jdk by reading in a jdk.dtd compliant XML
configuration file.
|
void |
doConfigure(String filename,
LogManager repository) |
void |
doConfigure(URL url,
LogManager repository) |
protected Handler |
findHandlerByName(Document doc,
String appenderName)
Used internally to parse appenders by IDREF name.
|
protected Handler |
findHandlerByReference(Element appenderRef)
Used internally to parse appenders by IDREF element.
|
protected void |
parse(Element element)
Used internally to configure the jdk framework by parsing a DOM
tree of XML elements based on jdk.dtd.
|
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,
Logger logger,
boolean isRoot)
Used internally to parse the children of a category element.
|
protected void |
parseErrorManager(Element element,
Handler appender)
Used internally to parse an
ErrorManager element. |
protected void |
parseFilters(Element element,
Handler appender)
Used internally to parse a filter element.
|
protected Handler |
parseHandler(Element appenderElement)
Used internally to parse an appender element.
|
protected Formatter |
parseLayout(Element layout_element)
Used internally to parse a layout element.
|
protected void |
parseLevel(Element element,
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 root category element.
|
protected void |
setParameter(Element elem,
Properties beanProps) |
protected String |
subst(String value) |
public DOMConfigurator()
public DOMConfigurator(ErrorManager errorLog)
public static void configure(Element element)
configuration
element as
defined in the jdk.dtd.element
- public static void configure(String filename) throws FactoryConfigurationError
doConfigure(String, LogManager)
.filename
- the file nameFactoryConfigurationError
- for any errorpublic static void configure(URL url) throws FactoryConfigurationError
doConfigure(java.net.URL, LogManager)
.url
- the urlFactoryConfigurationError
- for any errorpublic static void configure(InputStream is) throws FactoryConfigurationError
doConfigure(java.net.URL, LogManager)
.is
- the input streamFactoryConfigurationError
- for any errorprotected Handler findHandlerByName(Document doc, String appenderName)
doc
- the documentappenderName
- the appender nameprotected Handler findHandlerByReference(Element appenderRef)
appenderRef
- protected Handler parseHandler(Element appenderElement)
appenderElement
- the append elementprotected void parseErrorManager(Element element, Handler appender) throws Exception
ErrorManager
element.element
- the xml elementappender
- the appenderException
- for any errorprotected void parseFilters(Element element, Handler appender) throws Exception
element
- the xml elementappender
- the appenderException
- for any errorprotected void parseCategory(Element loggerElement) throws Exception
loggerElement
- the xml elementException
- for any errorprotected void parseCategoryFactory(Element factoryElement) throws Exception
factoryElement
- the xml elementException
- for any errorprotected void parseRoot(Element rootElement) throws Exception
rootElement
- the xml elementException
- for any errorprotected void parseChildrenOfLoggerElement(Element catElement, Logger logger, boolean isRoot) throws Exception
catElement
- the xml elementlogger
- the loggerisRoot
- whether this is the rootException
- for any errorprotected Formatter parseLayout(Element layout_element)
layout_element
- the xml elementprotected void parseRenderer(Element element)
protected void parseLevel(Element element, Logger logger, boolean isRoot)
element
- the elementlogger
- the loggerisRoot
- whether it is the rootprotected void setParameter(Element elem, Properties beanProps)
public void doConfigure(String filename, LogManager repository)
public void doConfigure(URL url, LogManager repository)
public void doConfigure(InputStream inputStream, LogManager repository) throws FactoryConfigurationError
inputStream
- repository
- FactoryConfigurationError
public void doConfigure(Reader reader, LogManager repository) throws FactoryConfigurationError
reader
- repository
- FactoryConfigurationError
protected void doConfigure(InputSource inputSource, LogManager repository) throws FactoryConfigurationError
inputSource
- repository
- FactoryConfigurationError
public void doConfigure(Element element, LogManager repository)
element
- repository
- protected void parse(Element element)
element
- protected void debug(String msg)
Copyright © 2013 JBoss, a division of Red Hat, Inc.. All Rights Reserved.