using System;using System.IO;using log4net;namespace JADAY.Frame.Common{ public class LogHelper { public static ILog LogInfo = LogManager.GetLogger("LogInfo"); public static ILog LogError = LogManager.GetLogger("LogError"); public static LogHelper Instance; public static LogHelper GetInstance() { return Instance ?? (Instance = new LogHelper()); } public LogHelper() { var file = new FileInfo(AppDomain.CurrentDomain.BaseDirectory + "\\App_Data\\log4net.cfg.xml"); log4net.Config.XmlConfigurator.Configure(file); } public static void SetConfig(FileInfo configFile) { log4net.Config.XmlConfigurator.Configure(configFile); } public static void SetConfig() { var file = new FileInfo(AppDomain.CurrentDomain.BaseDirectory + "\\App_Data\\log4net.cfg.xml"); log4net.Config.XmlConfigurator.Configure(file); } ////// 写日志 /// /// 信息 public void WriteInfo(string info) { if (LogInfo.IsInfoEnabled) { LogInfo.Info(info); } } ////// 写日志 /// /// 信息 public void WriteError(string info) { if (LogError.IsErrorEnabled) { LogError.Error(info); } } }}