usingSystem;usingSystem.Diagnostics; [Assembly:log4net. Config.xmlconfigurator (Watch=true)]namespacehbl.core{ Public Static classLog {/// <summary> ///General error/// </summary> /// <param name= "message" >message</param> Public Static voidError (Objectmessage) {log4net. ILog Log=log4net. Logmanager.getlogger (Getcurrentmethodfullname ()); Log. Error (message); } /// <summary> ///General error/// </summary> /// <param name= "message" >message</param> /// <param name= "Exception" >Exception</param> Public Static voidError (Objectmessage, Exception Exception) {log4net. ILog Log=log4net. Logmanager.getlogger (Getcurrentmethodfullname ()); Log. Error (message, exception); } /// <summary> ///Information/// </summary> /// <param name= "message" >message</param> Public Static voidInfo (Objectmessage) {log4net. ILog Log=log4net. Logmanager.getlogger (Getcurrentmethodfullname ()); Log. Info (message); } /// <summary> ///Information/// </summary> /// <param name= "message" >message</param> /// <param name= "Exception" >Exception</param> Public Static voidInfo (Objectmessage, Exception ex) {log4net. ILog Log=log4net. Logmanager.getlogger (Getcurrentmethodfullname ()); Log. Info (message, ex); } /// <summary> ///Warning/// </summary> /// <param name= "message" >message</param> Public Static voidWarn (Objectmessage) {log4net. ILog Log=log4net. Logmanager.getlogger (Getcurrentmethodfullname ()); Log. Warn (message); } /// <summary> ///Warning/// </summary> /// <param name= "message" >message</param> /// <param name= "Exception" >Exception</param> Public Static voidWarn (Objectmessage, Exception ex) {log4net. ILog Log=log4net. Logmanager.getlogger (Getcurrentmethodfullname ()); Log. Warn (message, ex); } /// <summary> ///Debug/// </summary> /// <param name= "message" >message</param> Public Static voidDebug (Objectmessage) {log4net. ILog Log=log4net. Logmanager.getlogger (Getcurrentmethodfullname ()); Log. Debug (message); } /// <summary> ///Debug/// </summary> /// <param name= "message" >message</param> /// <param name= "Exception" >Exception</param> Public Static voidDebug (Objectmessage, Exception ex) {log4net. ILog Log=log4net. Logmanager.getlogger (Getcurrentmethodfullname ()); Log. DEBUG (message, ex); } Static stringGetcurrentmethodfullname () {Try { intdepth =2; StackTrace St=NewStackTrace (); intMaxframes =St. Getframes (). Length; StackFrame SF; stringMethodName, ClassName; Type ClassType; Do{SF= St. GetFrame (depth++); ClassType=SF. GetMethod (). DeclaringType; ClassName=classtype.tostring (); } while(Classname.endswith ("Exception") && Depth <maxframes); MethodName=SF. GetMethod (). Name; returnClassName +"."+MethodName; } Catch { return NULL; } } }}
Classes that inherit Log4.net