using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Xml;
using log4net;
using log4net.Config;
namespace SuperSocket.SocketBase.Logging
{
///
/// Log4NetLogFactory
///
public class Log4NetLogFactory : LogFactoryBase
{
///
/// Initializes a new instance of the class.
///
public Log4NetLogFactory()
: this("log4net.config")
{
}
///
/// Initializes a new instance of the class.
///
/// The log4net config.
public Log4NetLogFactory(string log4netConfig)
: base(log4netConfig)
{
if (!IsSharedConfig)
{
log4net.Config.XmlConfigurator.Configure(new FileInfo(ConfigFile));
}
else
{
//Disable Performance logger
var xmlDoc = new XmlDocument();
xmlDoc.Load(ConfigFile);
var docElement = xmlDoc.DocumentElement;
var perfLogNode = docElement.SelectSingleNode("logger[@name='Performance']");
if (perfLogNode != null)
docElement.RemoveChild(perfLogNode);
log4net.Config.XmlConfigurator.Configure(docElement);
}
}
///
/// Gets the log by name.
///
/// The name.
///
public override ILog GetLog(string name)
{
return new Log4NetLog(LogManager.GetLogger(name));
}
}
}