You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
149 lines
3.3 KiB
C#
149 lines
3.3 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Text;
|
|
using System.IO;
|
|
using System.Globalization;
|
|
using log4net;
|
|
using log4net.Config;
|
|
|
|
namespace Mesnac.Equip.AllenBradley
|
|
{
|
|
public class Logger
|
|
{
|
|
#region 单例模式
|
|
ILog log;
|
|
private static Logger _this;
|
|
public static Logger Instance
|
|
{
|
|
get
|
|
{
|
|
if (null == _this)
|
|
_this = new Logger();
|
|
return _this;
|
|
}
|
|
}
|
|
private Logger()
|
|
{
|
|
XmlConfigurator.ConfigureAndWatch(new FileInfo(AppDomain.CurrentDomain.SetupInformation.ConfigurationFile));
|
|
log = LogManager.GetLogger(this.GetType());
|
|
}
|
|
#endregion
|
|
|
|
#region Debug
|
|
public void Debug(object message)
|
|
{
|
|
log.Debug(message);
|
|
}
|
|
|
|
public void DebugFormatted(string format, params object[] args)
|
|
{
|
|
log.DebugFormat(CultureInfo.InvariantCulture, format, args);
|
|
}
|
|
|
|
public bool IsDebugEnabled
|
|
{
|
|
get
|
|
{
|
|
return log.IsDebugEnabled;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region Info
|
|
public void Info(object message)
|
|
{
|
|
return;
|
|
log.Info(message);
|
|
}
|
|
|
|
public void InfoFormatted(string format, params object[] args)
|
|
{
|
|
log.InfoFormat(CultureInfo.InvariantCulture, format, args);
|
|
}
|
|
|
|
public bool IsInfoEnabled
|
|
{
|
|
get
|
|
{
|
|
return log.IsInfoEnabled;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region Warn
|
|
public void Warn(object message)
|
|
{
|
|
log.Warn(message);
|
|
}
|
|
|
|
public void Warn(object message, Exception exception)
|
|
{
|
|
log.Warn(message, exception);
|
|
}
|
|
|
|
public void WarnFormatted(string format, params object[] args)
|
|
{
|
|
log.WarnFormat(CultureInfo.InvariantCulture, format, args);
|
|
}
|
|
|
|
public bool IsWarnEnabled
|
|
{
|
|
get
|
|
{
|
|
return log.IsWarnEnabled;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region Error
|
|
public void Error(object message)
|
|
{
|
|
log.Error(message);
|
|
}
|
|
|
|
public void Error(object message, Exception exception)
|
|
{
|
|
log.Error(message, exception);
|
|
}
|
|
|
|
public void ErrorFormatted(string format, params object[] args)
|
|
{
|
|
log.ErrorFormat(CultureInfo.InvariantCulture, format, args);
|
|
}
|
|
|
|
public bool IsErrorEnabled
|
|
{
|
|
get
|
|
{
|
|
return log.IsErrorEnabled;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region Fatal
|
|
public void Fatal(object message)
|
|
{
|
|
log.Fatal(message);
|
|
}
|
|
|
|
public void Fatal(object message, Exception exception)
|
|
{
|
|
log.Fatal(message, exception);
|
|
}
|
|
|
|
public void FatalFormatted(string format, params object[] args)
|
|
{
|
|
log.FatalFormat(CultureInfo.InvariantCulture, format, args);
|
|
}
|
|
|
|
public bool IsFatalEnabled
|
|
{
|
|
get
|
|
{
|
|
return log.IsFatalEnabled;
|
|
}
|
|
}
|
|
#endregion
|
|
}
|
|
}
|