2

I want to create a new Windows log in Windows event viewer, everything seems to be fine but the log is not displaying. The source is being populated in Application log instead of the one I'm trying to create

enter image description here

Sample code

 if (!EventLog.SourceExists(sSource))
                EventLog.CreateEventSource(sSource, sLog);

1 Answers1

1

The reason is the permissions on registry. The files are on disk, but to been able to create a new log, your reference is on registry.

To been able to create a new log you must go to registry and give permission write for "asp.net pool user" - even ones for a server is good enough to create it.

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\EventLog

Open the registry editor, find this key, right click on it, and give the permissions.

From EventLog.CreateEventSource Method

Note
To create 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.

Aristos
  • 66,005
  • 16
  • 114
  • 150