XmlConfiguratorAttribute Class | Apache log4net™ SDK Documentation

Assembly level attribute to configure the XmlConfigurator.
Inheritance Hierarchy

System
Object
System
Attribute
log4net.Config
ConfiguratorAttribute
log4net.Config
XmlConfiguratorAttribute
log4net.Config
DOMConfiguratorAttribute

Namespace: log4net.Config
Assembly: log4net (in log4net.dll) Version: 2.0.8.0-.NET 4.0
Syntax

C#
VB
C++
F#
Copy

    [SerializableAttribute]
    public class XmlConfiguratorAttribute : ConfiguratorAttribute

    <SerializableAttribute>
    Public Class XmlConfiguratorAttribute
    	Inherits ConfiguratorAttribute

    [SerializableAttribute]
    public ref class XmlConfiguratorAttribute : public ConfiguratorAttribute

    [<SerializableAttribute>]
    type XmlConfiguratorAttribute =
        class
            inherit ConfiguratorAttribute
        end

The XmlConfiguratorAttribute type exposes the following members.

Constructors

| Name | Description
--- | --- | ---
| XmlConfiguratorAttribute | Default constructor

Top
Properties

| Name | Description
--- | --- | ---
| ConfigFile | Gets or sets the filename of the configuration file.
| ConfigFileExtension | Gets or sets the extension of the configuration file.
| TypeId | When implemented in a derived class, gets a unique identifier for this Attribute. (Inherited from Attribute.)
| Watch | Gets or sets a value indicating whether to watch the configuration file.

Top
Methods

| Name | Description
--- | --- | ---
| CompareTo | Compare this instance to another ConfiguratorAttribute (Inherited from ConfiguratorAttribute.)
| Configure | Configures the ILoggerRepository for the specified assembly. (Overrides ConfiguratorAttribute Configure(Assembly, ILoggerRepository).)
| Equals | Returns a value that indicates whether this instance is equal to a specified object. (Inherited from Attribute.)
| Finalize | Allows an Object to attempt to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection. (Inherited from Object.)
| GetHashCode | Returns the hash code for this instance. (Inherited from Attribute.)
| GetType | Gets the Type of the current instance. (Inherited from Object.)
| IsDefaultAttribute | When overridden in a derived class, indicates whether the value of this instance is the default value for the derived class. (Inherited from Attribute.)
| Match | When overridden in a derived class, returns a value that indicates whether this instance equals a specified object. (Inherited from Attribute.)
| MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.)
| ToString | Returns a String that represents the current Object. (Inherited from Object.)

Top
Remarks

This attribute may only be used at the assembly scope and can only be used once per assembly.

Use this attribute to configure the XmlConfigurator without calling one of the [M:XmlConfigurator.Configure()] methods.

If neither of the ConfigFile or ConfigFileExtension properties are set the configuration is loaded from the application's .config file. If set the ConfigFile property takes priority over the ConfigFileExtension property. The ConfigFile property specifies a path to a file to load the config from. The path is relative to the application's base directory; BaseDirectory. The ConfigFileExtension property is used as a postfix to the assembly file name. The config file must be located in the application's base directory; BaseDirectory. For example in a console application setting the ConfigFileExtension to config has the same effect as not specifying the ConfigFile or ConfigFileExtension properties.

The Watch property can be set to cause the XmlConfigurator to watch the configuration file for changes.

Note
Log4net will only look for assembly level configuration attributes once. When using the log4net assembly level attributes to control the configuration of log4net you must ensure that the first call to any of the LoggerManager methods is made from the assembly with the configuration attributes. If you cannot guarantee the order in which log4net calls will be made from different assemblies you must use programmatic configuration instead, i.e. call the [M:XmlConfigurator.Configure()] method directly.

See Also

#### Reference

log4net.Config Namespace