I'm using a third party application that provides an API to use their event logging system. I want to catch an exception at the method level in my code and pass that exception to the third party's event logging system. But I dont know how to extract the eventid, category and EventType from the standard Exception object so i can pass it to Write(string message, string category, int eventID, EventType eventType).
public EventLogs
{
private EventLogs()
{
}
public static void Write(EventLogEntry entry)
{
try
{
if (Globals.IsNullorEmpty(entry.MachineName))
{
entry.MachineName = Environment.MachineName;
}
if (!Globals.IsNullorEmpty(entry.Message))
{
entry.Message = Globals.HtmlEncode(entry.Message);
}
CommonDataProvider.Instance().WriteEventLogEntry(entry);
}
catch
{
}
}
public static void Write(string message, string category, int eventID, EventType eventType)
{
Write(message, category, eventID, eventType, -1);
}
public static void Write(string message, string category, int eventID, EventType eventType, int settingsID)
{
Write(new EventLogEntry { Message = message, Category = category, EventID = eventID, EventType = eventType, SettingsID = settingsID });
}
}