#region Apache License
//
// Licensed to the Apache Software Foundation (ASF) under one or more
// contributor license agreements. See the NOTICE file distributed with
// this work for additional information regarding copyright ownership.
// The ASF licenses this file to you under the Apache License, Version 2.0
// (the "License"); you may not use this file except in compliance with
// the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#endregion
#if NET_2_0 // really only because netstandard doesn't understand Assembly.GetCallingAssembly()
using System;
using System.Xml;
using System.Collections;
using System.IO;
using System.Reflection;
using System.Threading;
using log4net.Appender;
using log4net.Util;
using log4net.Repository;
namespace log4net.Config
{
///
/// Use this class to initialize the log4net environment using an Xml tree.
///
///
///
/// DOMConfigurator is obsolete. Use XmlConfigurator instead of DOMConfigurator.
///
///
/// Configures a using an Xml tree.
///
///
/// Nicko Cadell
/// Gert Driesen
[Obsolete("Use XmlConfigurator instead of DOMConfigurator")]
public sealed class DOMConfigurator
{
#region Private Instance Constructors
///
/// Private constructor
///
private DOMConfigurator()
{
}
#endregion Protected Instance Constructors
#region Configure static methods
///
/// Automatically configures the log4net system based on the
/// application's configuration settings.
///
///
///
/// DOMConfigurator is obsolete. Use XmlConfigurator instead of DOMConfigurator.
///
/// Each application has a configuration file. This has the
/// same name as the application with '.config' appended.
/// This file is XML and calling this function prompts the
/// configurator to look in that file for a section called
/// log4net that contains the configuration data.
///
[Obsolete("Use XmlConfigurator.Configure instead of DOMConfigurator.Configure")]
public static void Configure()
{
XmlConfigurator.Configure(LogManager.GetRepository(Assembly.GetCallingAssembly()));
}
///
/// Automatically configures the using settings
/// stored in the application's configuration file.
///
///
///
/// DOMConfigurator is obsolete. Use XmlConfigurator instead of DOMConfigurator.
///
/// Each application has a configuration file. This has the
/// same name as the application with '.config' appended.
/// This file is XML and calling this function prompts the
/// configurator to look in that file for a section called
/// log4net that contains the configuration data.
///
/// The repository to configure.
[Obsolete("Use XmlConfigurator.Configure instead of DOMConfigurator.Configure")]
public static void Configure(ILoggerRepository repository)
{
XmlConfigurator.Configure(repository);
}
///
/// Configures log4net using a log4net element
///
///
///
/// DOMConfigurator is obsolete. Use XmlConfigurator instead of DOMConfigurator.
///
/// Loads the log4net configuration from the XML element
/// supplied as .
///
/// The element to parse.
[Obsolete("Use XmlConfigurator.Configure instead of DOMConfigurator.Configure")]
public static void Configure(XmlElement element)
{
XmlConfigurator.Configure(LogManager.GetRepository(Assembly.GetCallingAssembly()), element);
}
///
/// Configures the using the specified XML
/// element.
///
///
///
/// DOMConfigurator is obsolete. Use XmlConfigurator instead of DOMConfigurator.
///
/// Loads the log4net configuration from the XML element
/// supplied as .
///
/// The repository to configure.
/// The element to parse.
[Obsolete("Use XmlConfigurator.Configure instead of DOMConfigurator.Configure")]
public static void Configure(ILoggerRepository repository, XmlElement element)
{
XmlConfigurator.Configure(repository, element);
}
///
/// Configures log4net using the specified configuration file.
///
/// The XML file to load the configuration from.
///
///
/// DOMConfigurator is obsolete. Use XmlConfigurator instead of DOMConfigurator.
///
///
/// The configuration file must be valid XML. It must contain
/// at least one element called log4net that holds
/// the log4net 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 following example configures log4net using a configuration file, of which the
/// location is stored in the application's configuration file :
///
///
/// using log4net.Config;
/// using System.IO;
/// using System.Configuration;
///
/// ...
///
/// DOMConfigurator.Configure(new FileInfo(ConfigurationSettings.AppSettings["log4net-config-file"]));
///
///
/// In the .config file, the path to the log4net can be specified like this :
///
///
///
///
///
///
///
///
///
[Obsolete("Use XmlConfigurator.Configure instead of DOMConfigurator.Configure")]
public static void Configure(FileInfo configFile)
{
XmlConfigurator.Configure(LogManager.GetRepository(Assembly.GetCallingAssembly()), configFile);
}
///
/// Configures log4net using the specified configuration file.
///
/// A stream to load the XML configuration from.
///
///
/// DOMConfigurator is obsolete. Use XmlConfigurator instead of DOMConfigurator.
///
///
/// The configuration data must be valid XML. It must contain
/// at least one element called log4net that holds
/// the log4net configuration data.
///
///
/// Note that this method will NOT close the stream parameter.
///
///
[Obsolete("Use XmlConfigurator.Configure instead of DOMConfigurator.Configure")]
public static void Configure(Stream configStream)
{
XmlConfigurator.Configure(LogManager.GetRepository(Assembly.GetCallingAssembly()), configStream);
}
///
/// Configures the using the specified configuration
/// file.
///
/// The repository to configure.
/// The XML file to load the configuration from.
///
///
/// DOMConfigurator is obsolete. Use XmlConfigurator instead of DOMConfigurator.
///
///
/// 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 following example configures log4net using a configuration file, of which the
/// location is stored in the application's configuration file :
///
///
/// using log4net.Config;
/// using System.IO;
/// using System.Configuration;
///
/// ...
///
/// DOMConfigurator.Configure(new FileInfo(ConfigurationSettings.AppSettings["log4net-config-file"]));
///
///
/// In the .config file, the path to the log4net can be specified like this :
///
///
///
///
///
///
///
///
///
[Obsolete("Use XmlConfigurator.Configure instead of DOMConfigurator.Configure")]
public static void Configure(ILoggerRepository repository, FileInfo configFile)
{
XmlConfigurator.Configure(repository, configFile);
}
///
/// Configures the using the specified configuration
/// file.
///
/// The repository to configure.
/// The stream to load the XML configuration from.
///
///
/// DOMConfigurator is obsolete. Use XmlConfigurator instead of DOMConfigurator.
///
///
/// The configuration data must be valid XML. It must contain
/// at least one element called log4net that holds
/// the configuration data.
///
///
/// Note that this method will NOT close the stream parameter.
///
///
[Obsolete("Use XmlConfigurator.Configure instead of DOMConfigurator.Configure")]
public static void Configure(ILoggerRepository repository, Stream configStream)
{
XmlConfigurator.Configure(repository, configStream);
}
#endregion Configure static methods
#region ConfigureAndWatch static methods
#if (!NETCF && !SSCLI)
///
/// Configures log4net using the file specified, monitors the file for changes
/// and reloads the configuration if a change is detected.
///
/// The XML file to load the configuration from.
///
///
/// DOMConfigurator is obsolete. Use XmlConfigurator instead of DOMConfigurator.
///
///
/// The configuration file must be valid XML. It must contain
/// at least one element called log4net that holds
/// the configuration data.
///
///
/// The configuration file will be monitored using a
/// and depends on the behavior of that class.
///
///
/// For more information on how to configure log4net using
/// a separate configuration file, see .
///
///
///
[Obsolete("Use XmlConfigurator.ConfigureAndWatch instead of DOMConfigurator.ConfigureAndWatch")]
public static void ConfigureAndWatch(FileInfo configFile)
{
XmlConfigurator.ConfigureAndWatch(LogManager.GetRepository(Assembly.GetCallingAssembly()), configFile);
}
///
/// Configures the using the file specified,
/// monitors the file for changes and reloads the configuration if a change
/// is detected.
///
/// The repository to configure.
/// The XML file to load the configuration from.
///
///
/// DOMConfigurator is obsolete. Use XmlConfigurator instead of DOMConfigurator.
///
///
/// The configuration file must be valid XML. It must contain
/// at least one element called log4net that holds
/// the configuration data.
///
///
/// The configuration file will be monitored using a
/// and depends on the behavior of that class.
///
///
/// For more information on how to configure log4net using
/// a separate configuration file, see .
///
///
///
[Obsolete("Use XmlConfigurator.ConfigureAndWatch instead of DOMConfigurator.ConfigureAndWatch")]
public static void ConfigureAndWatch(ILoggerRepository repository, FileInfo configFile)
{
XmlConfigurator.ConfigureAndWatch(repository, configFile);
}
#endif
#endregion ConfigureAndWatch static methods
}
}
#endif // NET_2_0