Posts

Showing posts with the label Events

Exception Handling (Exception logging)

using System; using System.Collections.Generic; using System.Text; using System.Diagnostics; namespace ExceptionLogger { public class ExceptionLogger { public static void WritetoCustomEventLog(Exception paramEntry, EventLogEntryType paramType) { string str_Source = "ERROR LOG"; //Source Name string str_LogType = "My Test LOG"; //Your log Name if it does not exists then first it will create and then add entry string str_Machine = "."; //machine name if (!System.Diagnostics.EventLog.SourceExists(str_Source, str_Machine)) { System.Diagnostics.EventLog.CreateEventSource(str_Source, str_LogType, str_Machine); } string ExceptionDetail = ""; ExceptionDetail = "Message : " + paramEntry.Message + "\n"; ExceptionDetail += "Stack Trace : " + paramEntry.StackTrace + "\n"; ...