ASP Errors
See log ASP errors with log4net or log ASP errors with health monitoring.
Errors
- Page level: Page_Error event (Server.ClearError if you don't want it to bubble up)
- Page level: Page directive <%@ Page ErrorPage="SpecificErrorPage.aspx" %>
- Application level: Application_Error() event in global.asax (NB error is InnerException as a HttpUnhandledException is wrapping it)
- Application level: web.config
<configuration>
<system.web>
<customErrors defaultRedirect="MyErrorPage.aspx" mode="remoteonly">
<error statusCode="404" redirect="/error/notfound.aspx"/>
</customErrors>
</system.web>
</configuration>
Error Logging
NB: Web.config customErrors/@defaultRedirect can't log (implicit Server.ClearError)
Global.asax Application_Error. This can obviate the customErrors/@defaultRedirect directive if you Server.ClearError() and redirect. See an example with log4net or an example with asp 2 health monitoring.
In ASP 2, put WebEventProviders in the web.config. (Quickstart, msdn)
"All Errors" doesn't pick up handled errors. Including those handled by Server.ClearError in Global.Application_Error
Event Log
ASP.Net cannot by default create a event log source (unless you use the ASP.Net 2 Health Monitoring source). (KB- either create a registry entry for it, or use System.Diagnostics.EventLogInstaller).