using System; using System.Diagnostics; using log4net; using log4net.Config; namespace Correlator.Util { public static class LogHelper { private static readonly ILog LogDebug = LogManager.GetLogger("logdebug"); private static readonly ILog LogInfo = LogManager.GetLogger("loginfo"); private static readonly ILog LogWarn = LogManager.GetLogger("logwarn"); private static readonly ILog LogError = LogManager.GetLogger("logerror"); private static readonly ILog LogFatal = LogManager.GetLogger("logfatal"); public static void Debug(string msg) { var sf = new StackFrame(1); msg = $"{sf.GetMethod().ReflectedType?.FullName}.{sf.GetMethod().Name}:{msg}"; LogDebug.Debug(msg); } public static void Debug(string msg, Exception e) { var sf = new StackFrame(1); msg = $"{sf.GetMethod().ReflectedType?.FullName}.{sf.GetMethod().Name}:{msg}"; LogDebug.Debug(msg, e); } public static void Info(string msg) { var sf = new StackFrame(1); msg = $"{sf.GetMethod().ReflectedType?.FullName}.{sf.GetMethod().Name}:{msg}"; LogInfo.Info(msg); } public static void Info(string msg, Exception e) { var sf = new StackFrame(1); msg = $"{sf.GetMethod().ReflectedType?.FullName}.{sf.GetMethod().Name}:{msg}"; LogInfo.Info(msg, e); } public static void Warn(string msg) { var sf = new StackFrame(1); msg = $"{sf.GetMethod().ReflectedType?.FullName}.{sf.GetMethod().Name}:{msg}"; LogWarn.Warn(msg); } public static void Warn(string msg, Exception e) { var sf = new StackFrame(1); msg = $"{sf.GetMethod().ReflectedType?.FullName}.{sf.GetMethod().Name}:{msg}"; LogWarn.Warn(msg, e); } public static void Error(string msg) { var sf = new StackFrame(1); msg = $"{sf.GetMethod().ReflectedType?.FullName}.{sf.GetMethod().Name}:{msg}"; LogError.Error(msg); } public static void Error(string msg, Exception e) { var sf = new StackFrame(1); msg = $"{sf.GetMethod().ReflectedType?.FullName}.{sf.GetMethod().Name}:{msg}"; LogError.Error(msg, e); } public static void Fatal(string msg) { var sf = new StackFrame(1); msg = $"{sf.GetMethod().ReflectedType?.FullName}.{sf.GetMethod().Name}:{msg}"; LogFatal.Fatal(msg); } public static void Fatal(string msg, Exception e) { var sf = new StackFrame(1); msg = $"{sf.GetMethod().ReflectedType?.FullName}.{sf.GetMethod().Name}:{msg}"; LogFatal.Fatal(msg, e); } } }