對已LogHelper,形如:
public static void WriteError(string className,string methodName,string message) { //... } public static void WriteDebug(string className, string methodName, string message) { //... }
大家都知道要干嘛,調用時這樣的:
LogHelper.WriteDebug("BusFlowBase", "DoWork", string.Format("公司在平台查詢訂單查詢完畢。"));
public static void WriteError(string message) { var sf = new StackFrame(1); //1表示離棧頂還差一個。 var callMethod = sf.GetMethod(); WriteError(callMethod.DeclaringType.Name, callMethod.Name, message); } public static void WriteError(string className, string methodName, string message) { //... } public static void WriteDebug(string message) { var sf = new StackFrame(1); var callMethod = sf.GetMethod(); WriteDebug(callMethod.DeclaringType.Name, callMethod.Name, message); } public static void WriteDebug(string className, string methodName, string message) { //... }
調用時這樣的:
LogHelper.WriteDebug( string.Format("公司在平台查詢訂單查詢完畢。"));
舒服吧?!!!