Writing to the Event Log in ASP.NET is a piece of cake. The following is a static class that I have used time and time again to simply encapsulate the event logging writing code:
This class works great in a console application where you can run as administrator. However, when you try to run from an ASP.NET application for the first time on a new event source, most often you will get permission denied:
Requested Registry Access Is Not Allowed
For security purposes the ASP.NET application will run under a limited role (at least it should be). This limited role prevents the application from having permission to create a new event log source. The solution is simple… you can manually add in an event log source which will prevent the application from trying to create one (all apps can write a log, just not create an event source).
Here are some steps, however, be warned this is manually changing some registry settings – make sure you backup and complete at your own risk:
Check out some further MSDN notes and explanations here: http://support.microsoft.com/kb/329291