If this is for ASP.NET, you can add the file Global.asaxto the site and process the method Application_Error.
This is how I usually use it:
void Application_Error(object sender, EventArgs e)
{
if (!System.Diagnostics.EventLog.SourceExists("MySource"))
{
System.Diagnostics.EventLog.CreateEventSource("MySource",
"Application");
}
System.Diagnostics.EventLog.WriteEntry("MySource",
Server.GetLastError().ToString());
}
source
share