log4net SDK Reference |

# XmlConfigurator.Configure Method (ILoggerRepository, FileInfo)

Configures the ILoggerRepository using the specified configuration file.

[Visual Basic]
Overloads Public Shared Sub Configure( _
ByVal repository As ILoggerRepository, _
ByVal configFile As FileInfo _
)
[C#]
public static void Configure(
ILoggerRepository repository,
FileInfo configFile
);

#### Parameters

repository
  The repository to configure.
configFile
  The XML file to load the configuration from.

#### Remarks

The configuration file must be valid XML. It must contain at least one element called `log4net` that holds the configuration data.

The log4net configuration file can possible be specified in the application's configuration file (either `MyAppName.exe.config` for a normal application on `Web.config` for an ASP.NET application).

The first element matching `<configuration>` will be read as the configuration. If this file is also a .NET .config file then you must specify a configuration section for the `log4net` element otherwise .NET will complain. Set the type for the section handler to IgnoreSectionHandler, for example:

    [XML]
    <configSections>
        <section name="log4net" type="System.Configuration.IgnoreSectionHandler" />
    </configSections>

The following example configures log4net using a configuration file, of which the location is stored in the application's configuration file :

    [C#]
    using log4net.Config;
    using System.IO;
    using System.Configuration;

    ...

    XmlConfigurator.Configure(new FileInfo(ConfigurationSettings.AppSettings["log4net-config-file"]));

In the `.config` file, the path to the log4net can be specified like this :

    [XML]
    <configuration>
        <appSettings>
            <add key="log4net-config-file" value="log.config" />
        </appSettings>
    </configuration>

#### See Also

XmlConfigurator Class | log4net.Config Namespace | XmlConfigurator.Configure Overload List