So in the past I have always sent run time error (any plenty of other types of errors) is a catch all type email address. I don’t have any real reason for this other than that was how it done by the programmers before me. Much past that I had never really put much more thought into it. Until now…
With the upgrades to Windows Server and IIS 7 the event log is no longer a place I dread going. It as some filters, doesn’t load as slow, and finally works in a manner that is in my opinion actually usable by your everyday System Admin. With that being said… why send all those errors to an email address.
To set this up and be a very small pain, but in the end I think it is worth the Hassle. The only thing that you have to keep in mind is that you have to register your application with windows via REGEDIT. After you have done that, the code is as simple as creating a new Event Object and writing the event to it.
Here is the error you see if the application is not registered with the server. System.Security.SecurityException: Requested registry access is not allowed.
Instead, go to registry editor (regedit), locate key HKEY_LOCAL_MACHINESYSTEMCurrentControlSetServicesEventlogApplication
and create a new key with the source name
If your event log has some junk pre-pended to the Log Entry you need to make sure that the user associated with the application pool running the site has access to write to the event log.
This articles references this post.