Class XmlConfiguration
- java.lang.Object
-
- org.apache.logging.log4j.core.AbstractLifeCycle
-
- org.apache.logging.log4j.core.filter.AbstractFilterable
-
- org.apache.logging.log4j.core.config.AbstractConfiguration
-
- org.apache.logging.log4j.core.config.xml.XmlConfiguration
-
- All Implemented Interfaces:
Configuration
,Reconfigurable
,Filterable
,LifeCycle
,LifeCycle2
public class XmlConfiguration extends AbstractConfiguration implements Reconfigurable
Creates a Node hierarchy from an XML file.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
XmlConfiguration.ErrorType
The error that occurred.private static class
XmlConfiguration.Status
Status for recording errors.-
Nested classes/interfaces inherited from class org.apache.logging.log4j.core.filter.AbstractFilterable
AbstractFilterable.Builder<B extends AbstractFilterable.Builder<B>>
-
Nested classes/interfaces inherited from interface org.apache.logging.log4j.core.LifeCycle
LifeCycle.State
-
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.String
LOG4J_XSD
private org.w3c.dom.Element
rootElement
private java.lang.String
schemaResource
private java.util.List<XmlConfiguration.Status>
status
private boolean
strict
private static java.lang.String[]
VERBOSE_CLASSES
private static java.lang.String
XINCLUDE_FIXUP_BASE_URIS
private static java.lang.String
XINCLUDE_FIXUP_LANGUAGE
-
Fields inherited from class org.apache.logging.log4j.core.config.AbstractConfiguration
isShutdownHookEnabled, listeners, pluginManager, pluginPackages, rootNode, scriptManager, shutdownTimeoutMillis
-
Fields inherited from class org.apache.logging.log4j.core.AbstractLifeCycle
DEFAULT_STOP_TIMEOUT, DEFAULT_STOP_TIMEUNIT, LOGGER
-
Fields inherited from interface org.apache.logging.log4j.core.config.Configuration
CONTEXT_PROPERTIES
-
-
Constructor Summary
Constructors Constructor Description XmlConfiguration(LoggerContext loggerContext, ConfigurationSource configSource)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
constructHierarchy(Node node, org.w3c.dom.Element element)
private static void
disableDtdProcessing(javax.xml.parsers.DocumentBuilderFactory factory)
private static void
enableXInclude(javax.xml.parsers.DocumentBuilderFactory factory)
Enables XInclude for the given DocumentBuilderFactoryprivate java.lang.String
getType(org.w3c.dom.Element element)
(package private) static javax.xml.parsers.DocumentBuilder
newDocumentBuilder(boolean xIncludeAware)
Creates a new DocumentBuilder suitable for parsing a configuration file.private java.util.Map<java.lang.String,java.lang.String>
processAttributes(Node node, org.w3c.dom.Element element)
Configuration
reconfigure()
private static void
setFeature(javax.xml.parsers.DocumentBuilderFactory factory, java.lang.String featureName, boolean value)
void
setup()
java.lang.String
toString()
-
Methods inherited from class org.apache.logging.log4j.core.config.AbstractConfiguration
addAppender, addComponent, addListener, addLogger, addLoggerAppender, addLoggerFilter, createAdvertiser, createConfiguration, doConfigure, getAdvertiser, getAppender, getAppenders, getAsyncLoggerConfigDelegate, getComponent, getConfigurationSource, getCustomLevels, getDefaultStatus, getLogger, getLoggerConfig, getLoggerContext, getLoggers, getName, getNanoClock, getPluginManager, getPluginPackages, getProperties, getReliabilityStrategy, getRootLogger, getRootNode, getScheduler, getScriptManager, getShutdownTimeoutMillis, getStrSubstitutor, getWatchManager, initialize, initializeWatchers, isShutdownHookEnabled, preConfigure, removeAppender, removeListener, removeLogger, setAdvertiser, setLoggerAdditive, setName, setNanoClock, setPluginManager, setScriptManager, setToDefault, start, stop, toByteArray
-
Methods inherited from class org.apache.logging.log4j.core.filter.AbstractFilterable
addFilter, getFilter, getPropertyArray, hasFilter, isFiltered, removeFilter, stop
-
Methods inherited from class org.apache.logging.log4j.core.AbstractLifeCycle
equalsImpl, getState, getStatusLogger, hashCodeImpl, isInitialized, isStarted, isStarting, isStopped, isStopping, setStarted, setStarting, setState, setStopped, setStopping, stop, stop
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.apache.logging.log4j.core.filter.Filterable
addFilter, getFilter, hasFilter, isFiltered, removeFilter
-
-
-
-
Field Detail
-
XINCLUDE_FIXUP_LANGUAGE
private static final java.lang.String XINCLUDE_FIXUP_LANGUAGE
- See Also:
- Constant Field Values
-
XINCLUDE_FIXUP_BASE_URIS
private static final java.lang.String XINCLUDE_FIXUP_BASE_URIS
- See Also:
- Constant Field Values
-
VERBOSE_CLASSES
private static final java.lang.String[] VERBOSE_CLASSES
-
LOG4J_XSD
private static final java.lang.String LOG4J_XSD
- See Also:
- Constant Field Values
-
status
private final java.util.List<XmlConfiguration.Status> status
-
rootElement
private org.w3c.dom.Element rootElement
-
strict
private boolean strict
-
schemaResource
private java.lang.String schemaResource
-
-
Constructor Detail
-
XmlConfiguration
public XmlConfiguration(LoggerContext loggerContext, ConfigurationSource configSource)
-
-
Method Detail
-
newDocumentBuilder
static javax.xml.parsers.DocumentBuilder newDocumentBuilder(boolean xIncludeAware) throws javax.xml.parsers.ParserConfigurationException
Creates a new DocumentBuilder suitable for parsing a configuration file.- Parameters:
xIncludeAware
- enabled XInclude- Returns:
- a new DocumentBuilder
- Throws:
javax.xml.parsers.ParserConfigurationException
-
disableDtdProcessing
private static void disableDtdProcessing(javax.xml.parsers.DocumentBuilderFactory factory)
-
setFeature
private static void setFeature(javax.xml.parsers.DocumentBuilderFactory factory, java.lang.String featureName, boolean value)
-
enableXInclude
private static void enableXInclude(javax.xml.parsers.DocumentBuilderFactory factory)
Enables XInclude for the given DocumentBuilderFactory- Parameters:
factory
- a DocumentBuilderFactory
-
setup
public void setup()
- Overrides:
setup
in classAbstractConfiguration
-
reconfigure
public Configuration reconfigure()
- Specified by:
reconfigure
in interfaceReconfigurable
-
constructHierarchy
private void constructHierarchy(Node node, org.w3c.dom.Element element)
-
getType
private java.lang.String getType(org.w3c.dom.Element element)
-
processAttributes
private java.util.Map<java.lang.String,java.lang.String> processAttributes(Node node, org.w3c.dom.Element element)
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-