Event Viewer Logging in C#

I spent the morning writing a Transport Agent for Exchange 2010 (another story!) to log some emails to disk. As it was on a remote server and remote debugging wasn’t possible, I decided to log some details to the event log. Now this must be the first time I’ve had to write the logging mechanism myself because I’ve never come across this before. When you try to use the EventLog.WriteEntry method you need to pass the source of the message (i.e the application name). So when I did this I get the following exception:

The source was not found, but some or all event logs could not be searched. To create the source, you need permission to read all event logs to make sure that the new source name is unique. Inaccessible logs: Security.

Continue reading Event Viewer Logging in C#