Class XmlConfiguration

All Implemented Interfaces:
Configuration, Reconfigurable, Filterable, LifeCycle, LifeCycle2

public class XmlConfiguration extends Log4j1Configuration
Class Description goes here.
  • Field Details

  • Constructor Details

  • Method Details

    • addAppenderIfAbsent

      public void addAppenderIfAbsent(Appender appender)
    • doConfigure

      public void doConfigure() throws FactoryConfigurationError
      Configures log4j by reading in a log4j.dtd compliant XML configuration file.
      Overrides:
      doConfigure in class AbstractConfiguration
      Throws:
      FactoryConfigurationError
    • doConfigure

      private void doConfigure(XmlConfiguration.ParseAction action) throws FactoryConfigurationError
      Throws:
      FactoryConfigurationError
    • reconfigure

      public Configuration reconfigure()
      Specified by:
      reconfigure in interface Reconfigurable
      Overrides:
      reconfigure in class Log4j1Configuration
    • parseUnrecognizedElement

      private 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
    • quietParseUnrecognizedElement

      private 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
    • subst

      public 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.
    • setParameter

      public void setParameter(Element elem, 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 Object parseElement(Element element, Properties props, Class expectedClass) throws Exception
      Creates an object 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
    • findAppenderByName

      private Appender findAppenderByName(Document doc, String appenderName)
      Used internally to parse appenders by IDREF name.
    • findAppenderByReference

      public Appender findAppenderByReference(Element appenderRef)
      Used internally to parse appenders by IDREF element.
      Parameters:
      appenderRef - The Appender Reference Element.
      Returns:
      The Appender.
    • parseAppender

      public Appender parseAppender(Element appenderElement)
      Used internally to parse an appender element.
      Parameters:
      appenderElement - The Appender Element.
      Returns:
      The Appender.
    • buildAppender

      private Appender buildAppender(String className, Element appenderElement)
    • parseRewritePolicy

      public RewritePolicy parseRewritePolicy(Element rewritePolicyElement)
    • buildRewritePolicy

      private RewritePolicy buildRewritePolicy(String className, Element element)
    • parseErrorHandler

      private void parseErrorHandler(Element element, Appender appender)
      Used internally to parse an ErrorHandler element.
    • addFilter

      public void addFilter(AtomicReference<Filter> ref, Element filterElement)
      Used internally to parse a filter element.
      Parameters:
      filterElement - The Filter Element.
    • parseFilters

      public Filter parseFilters(Element filterElement)
      Used internally to parse a filter element.
    • buildFilter

      private Filter buildFilter(String className, Element filterElement)
    • parseCategory

      private void parseCategory(Element loggerElement)
      Used internally to parse an category element.
    • parseRoot

      private void parseRoot(Element rootElement)
      Used internally to parse the root category element.
    • parseChildrenOfLoggerElement

      private void parseChildrenOfLoggerElement(Element catElement, LoggerConfig loggerConfig, boolean isRoot)
      Used internally to parse the children of a LoggerConfig element.
    • parseLayout

      public Layout parseLayout(Element layoutElement)
      Used internally to parse a layout element.
      Parameters:
      layoutElement - The Layout Element.
      Returns:
      The Layout.
    • buildLayout

      private Layout buildLayout(String className, Element layout_element)
    • parseTriggeringPolicy

      public TriggeringPolicy parseTriggeringPolicy(Element policyElement)
    • parseLevel

      private void parseLevel(Element element, LoggerConfig logger, boolean isRoot)
      Used internally to parse a level element.
    • setParameter

      private void setParameter(Element element, PropertySetter propSetter)
    • parse

      private void parse(Element element)
      Used internally to configure the log4j framework by parsing a DOM tree of XML elements based on log4j.dtd.
    • subst

      private String subst(String value)
    • forEachElement

      public static void forEachElement(NodeList list, Consumer<Element> consumer)