Table of Contents

Class XmlHierarchyConfigurator

Namespace
log4net.Repository.Hierarchy
Assembly
log4net.dll

Initializes the log4net environment using an XML DOM.

public class XmlHierarchyConfigurator
Inheritance
XmlHierarchyConfigurator
Inherited Members

Remarks

Configures a Hierarchy using an XML DOM.

Constructors

XmlHierarchyConfigurator(Hierarchy)

Construct the configurator for a hierarchy

public XmlHierarchyConfigurator(Hierarchy hierarchy)

Parameters

hierarchy Hierarchy

The hierarchy to build.

Remarks

Initializes a new instance of the XmlHierarchyConfigurator class with the specified Hierarchy.

Methods

Configure(XmlElement)

Configure the hierarchy by parsing a DOM tree of XML elements.

public void Configure(XmlElement element)

Parameters

element XmlElement

The root element to parse.

Remarks

Configure the hierarchy by parsing a DOM tree of XML elements.

ConvertStringTo(Type, string)

Converts a string value to a target type.

protected object ConvertStringTo(Type type, string value)

Parameters

type Type

The type of object to convert the string to.

value string

The string value to use as the value of the object.

Returns

object

An object of type type with value value or null when the conversion could not be performed.

CreateObjectFromXml(XmlElement, Type, Type)

Creates an object as specified in XML.

protected object CreateObjectFromXml(XmlElement element, Type defaultTargetType, Type typeConstraint)

Parameters

element XmlElement

The XML element that contains the definition of the object.

defaultTargetType Type

The object type to use if not explicitly specified.

typeConstraint Type

The type that the returned object must be or must inherit from.

Returns

object

The object or null

Remarks

Parse an XML element and create an object instance based on the configuration data.

The type of the instance may be specified in the XML. If not specified then the defaultTargetType is used as the type. However the type is specified it must support the typeConstraint type.

FindAppenderByReference(XmlElement)

Parse appenders by IDREF.

protected IAppender FindAppenderByReference(XmlElement appenderRef)

Parameters

appenderRef XmlElement

The appender ref element.

Returns

IAppender

The instance of the appender that the ref refers to.

Remarks

Parse an XML element that represents an appender and return the appender.

ParseAppender(XmlElement)

Parses an appender element.

protected IAppender ParseAppender(XmlElement appenderElement)

Parameters

appenderElement XmlElement

The appender element.

Returns

IAppender

The appender instance or null when parsing failed.

Remarks

Parse an XML element that represents an appender and return the appender instance.

ParseChildrenOfLoggerElement(XmlElement, Logger, bool)

Parses the children of a logger element.

protected void ParseChildrenOfLoggerElement(XmlElement catElement, Logger log, bool isRoot)

Parameters

catElement XmlElement

The category element.

log Logger

The logger instance.

isRoot bool

Flag to indicate if the logger is the root logger.

Remarks

Parse the child elements of a <logger> element.

ParseLevel(XmlElement, Logger, bool)

Parses a level element.

protected void ParseLevel(XmlElement element, Logger log, bool isRoot)

Parameters

element XmlElement

The level element.

log Logger

The logger object to set the level on.

isRoot bool

Flag to indicate if the logger is the root logger.

Remarks

Parse an XML element that represents a level.

ParseLogger(XmlElement)

Parses a logger element.

protected void ParseLogger(XmlElement loggerElement)

Parameters

loggerElement XmlElement

The logger element.

Remarks

Parse an XML element that represents a logger.

ParseRenderer(XmlElement)

Parses an object renderer.

protected void ParseRenderer(XmlElement element)

Parameters

element XmlElement

The renderer element.

Remarks

Parse an XML element that represents a renderer.

ParseRoot(XmlElement)

Parses the root logger element.

protected void ParseRoot(XmlElement rootElement)

Parameters

rootElement XmlElement

The root element.

Remarks

Parse an XML element that represents the root logger.

SetParameter(XmlElement, object)

Sets a parameter on an object.

protected void SetParameter(XmlElement element, object target)

Parameters

element XmlElement

The parameter element.

target object

The object to set the parameter on.

Remarks

The parameter name must correspond to a writable property on the object. The value of the parameter is a string, therefore this function will attempt to set a string property first. If unable to set a string property it will inspect the property and its argument type. It will attempt to call a static method called Parse on the type of the property. This method will take a single string argument and return a value that can be used to set the property.