Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void LogException(string ErrorDescription)
- {
- // The name of our log in the event logs
- string Log = “AspNetError”;
- // Check to see fi the log for AspNetError exists on the machine
- // If not, create it
- if ((!(EventLog.SourceExists(Log))))
- {
- EventLog.CreateEventSource(Log, Log);
- }
- // Now insert your exception information into the AspNetError event log
- EventLog logEntry = new EventLog();
- logEntry.Source = Log;
- logEntry.WriteEntry(ErrorDescription, EventLogEntryType.Error);
- }
- // Usage
- try
- {
- ThrowException();
- }
- catch (Exception exp)
- {
- LogException(exp.ToString());
- throw; // or whatever you want to do with it
- }
Advertisement
Add Comment
Please, Sign In to add comment