1 usinglog4net;2 usingSystem;3 usingSystem.Collections.Generic;4 usingSystem.Diagnostics;5 usingSystem.Linq;6 usingsystem.web;7 8 namespaceTrylittle.helper9 {Ten Public Static classLog One { A Public Static voidDebug (Objectmessage) - { - Logmanager.getlogger (Getcurrentmethodfullname ()). Debug (message); the } - - Public Static voidDebug (Objectmessage, Exception ex) - { + Logmanager.getlogger (Getcurrentmethodfullname ()). DEBUG (message, ex); - } + A Public Static voidError (Objectmessage) at { - Logmanager.getlogger (Getcurrentmethodfullname ()). Error (message); - } - - Public Static voidError (Objectmessage, Exception Exception) - { in Logmanager.getlogger (Getcurrentmethodfullname ()). Error (message, exception); - } to + Private Static stringGetcurrentmethodfullname () - { the Try * { $ stackframe frame;Panax Notoginseng stringstr2; - intnum =2; theStackTrace trace =NewStackTrace (); + intLength =Trace. Getframes (). Length; A Do the { +frame = trace. GetFrame (num++); -STR2 =frame. GetMethod (). Declaringtype.tostring (); $ } $ while(str2. EndsWith ("Exception") && (Num <length)); - stringName =frame. GetMethod (). Name; - return(STR2 +"."+name); the } - CatchWuyi { the return NULL; - } Wu } - About Public Static voidInfo (Objectmessage) $ { - Logmanager.getlogger (Getcurrentmethodfullname ()). Info (message); - } - A Public Static voidInfo (Objectmessage, Exception ex) + { the Logmanager.getlogger (Getcurrentmethodfullname ()). Info (message, ex); - } $ the Public Static voidWarn (Objectmessage) the { the Logmanager.getlogger (Getcurrentmethodfullname ()). Warn (message); the } - in Public Static voidWarn (Objectmessage, Exception ex) the { the Logmanager.getlogger (Getcurrentmethodfullname ()). Warn (message, ex); About } the the } the}View Code
Note: If you want to use this class in your project, you must first apply Log4net
Log4net-based Help class log