using System; using System.Diagnostics; using log4net; using log4net.Config; [assembly: XmlConfigurator(ConfigFile = "config/log4net.config",Watch = true)] namespace WorldGIS { public class LogHelper { private static ILog _logdebug = log4net.LogManager.GetLogger("logdebug"); private static ILog _loginfo = log4net.LogManager.GetLogger("loginfo"); private static ILog _logwarn = log4net.LogManager.GetLogger("logwarn"); private static ILog _logerror = log4net.LogManager.GetLogger("logerror"); private static ILog _logfatal = log4net.LogManager.GetLogger("logfatal"); public static void Debug(string msg) { StackFrame sf = new StackFrame(1); msg = string.Format("{0}.{1}:{2}", sf.GetMethod().ReflectedType.FullName, sf.GetMethod().Name, msg); _logdebug.Debug(msg); } public static void Debug(string msg, Exception e) { StackFrame sf = new StackFrame(1); msg = string.Format("{0}.{1}:{2}", sf.GetMethod().ReflectedType.FullName, sf.GetMethod().Name, msg); _logdebug.Debug(msg, e); } public static void Info(string msg) { StackFrame sf = new StackFrame(1); msg = string.Format("{0}.{1}:{2}", sf.GetMethod().ReflectedType.FullName, sf.GetMethod().Name, msg); _loginfo.Info(msg); } public static void Info(string msg, Exception e) { StackFrame sf = new StackFrame(1); msg = string.Format("{0}.{1}:{2}", sf.GetMethod().ReflectedType.FullName, sf.GetMethod().Name, msg); _loginfo.Info(msg, e); } public static void Warn(string msg) { StackFrame sf = new StackFrame(1); msg = string.Format("{0}.{1}:{2}", sf.GetMethod().ReflectedType.FullName, sf.GetMethod().Name, msg); _logwarn.Warn(msg); } public static void Warn(string msg, Exception e) { StackFrame sf = new StackFrame(1); msg = string.Format("{0}.{1}:{2}", sf.GetMethod().ReflectedType.FullName, sf.GetMethod().Name, msg); _logwarn.Warn(msg, e); } public static void Error(string msg) { StackFrame sf = new StackFrame(1); msg = string.Format("{0}.{1}:{2}", sf.GetMethod().ReflectedType.FullName, sf.GetMethod().Name, msg); _logerror.Error(msg); } public static void Error(string msg, Exception e) { StackFrame sf = new StackFrame(1); msg = string.Format("{0}.{1}:{2}", sf.GetMethod().ReflectedType.FullName, sf.GetMethod().Name, msg); _logerror.Error(msg, e); } public static void Fatal(string msg) { StackFrame sf = new StackFrame(1); msg = string.Format("{0}.{1}:{2}", sf.GetMethod().ReflectedType.FullName, sf.GetMethod().Name, msg); _logfatal.Fatal(msg); } public static void Fatal(string msg, Exception e) { StackFrame sf = new StackFrame(1); msg = string.Format("{0}.{1}:{2}", sf.GetMethod().ReflectedType.FullName, sf.GetMethod().Name, msg); _logfatal.Fatal(msg, e); } } }