Event Log – System.Security.SecurityException: The source was not found, but some or all event logs could not be searched. Inaccessible logs: Security


Event Log – System.Security.SecurityException: The source was not found, but some or all event logs could not be searched. Inaccessible logs: Security

This is a common error specially if you’re using Windows Server 2008 and higher, error means that the application/program that’s trying to write to event log with source not registered properly. Take the sample code below as an example:

EventLog.WriteEntry(“,”Message”);

During the deployment you can register the source by entering the ff command in the command prompt (Run as Administrator):

eventcreate /ID 1 /L APPLICATION /T INFORMATION /SO  /D “Registering”

If for some  reason you don’t know the source is and it’s throwing the error do the following:

Start -> Run -> regedit.exe Navigate to My Computer > HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\EventLog

in the Permissions, and grant the identity wherein the application/server is running with read/write permissions.

You will see the source that you need to register in the Event Log.