0
votes

By default ASP.NET writes any unhandled exception to the default ASP.NET X.Y.Z.0 event log source. Is it possible to specify either configuration that the events and exceptions for a particular application has to be logged in a specific event log Source?

The reason is that I would want all issues directly related to my application to be stored in a separate event log category that can then be filtered against.

1

1 Answers

0
votes

I've never done this before, but could you use the Global.Application_Error() method and use syntax like this within it:

   Exception ex = Server.GetLastError().GetBaseException();

   //log to Event Log
   EventLog.WriteEntry("Whatever",
     "MESSAGE: " + ex.Message + 
     "\nSOURCE: " + ex.Source +
     "\nFORM: " + Request.Form.ToString() + 
     "\nQUERYSTRING: " + Request.QueryString.ToString() +
     "\nTARGETSITE: " + ex.TargetSite +
     "\nSTACKTRACE: " + ex.StackTrace, 
     EventLogEntryType.Error);