C# EventLog Inaccessible Log C# EventLog Inaccessible Log windows windows

C# EventLog Inaccessible Log


Microsoft requires that you be an administrator in order to execute this method for the very reason that you found.

Here is their explanation (from the MSDN documentation):

To search for an event source in Windows Vista and later or Windows Server 2003, you must have administrative privileges.

The reason for this requirement is that all event logs, including security, must be searched to determine whether the event source is unique. Starting with Windows Vista, users do not have permission to access the security log; therefore, a SecurityException is thrown.

How you work around it will depend entirely on exactly what you need to do. The best recommendation if you are not able to log in as an administrator is to attempt to perform your action in a try/catch block and if a SecurityException is thrown, perform some alternate action.


Accessing some EventLogs requires elevation. Run the app as an administrator instead.


I recommend to use Logging Application Block of Enterprise Library in order to implement the correct logging.

Start reading from here