ProblemI received the following error message while attempting to log an entry in the event log using
System.Diagnostics.EventLog.WriteEntry(String message, EventLogEntryType type)System.Security.SecurityException: The source was not found, but some or all event logs could not be searched. Inaccessible logs: Security.
This would only occur when running my ASP.NET web application under Windows XP Professional. It does not occur when I push the site to production Windows 2003 web server.
SolutionAfter searching Google, I found
this forum thread, which lead me to this
KB article.
The solution that worked for me was under the "First Approach" heading. Here it is verbatim:
Create an event source under the Application event log in Registry Editor. To do this, follow these steps:
1. Click Start, and then click Run.
2. In the Open text box, type regedit.
3. Locate the following registry subkey:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Eventlog\Application
4. Right-click the Application subkey, point to New, and then click Key.
5. Type TEST for the key name.
6. Close Registry Editor.
Note: "TEST" should be replaced by whatever text you set the EventLog Source property to.
Update (05/02/07): I used this same fix when I get the error message "Registry access is not allowed".