public static void Fatal(string msg, bool console = false) { //调用堆栈 StackTrace trace = new StackTrace(); //调用本方法的方法 MethodBase method = trace.GetFrame(1).GetMethod(); Type type = method.DeclaringType; string methName = method != null ? method.Name : string.Empty; string message = "[" + methName + "(...)]" + msg; //var type = MethodBase.GetCurrentMethod().DeclaringType; log4net.ILog log = log4net.LogManager.GetLogger(type); log.FatalExt(message); if (console) { Console.WriteLine(msg); } }