C # Event Logging in Windows 7/2008 Server

I am trying to make an event logger for my cmd application. However, I get this error when she tries to create a log for the first time.

Source not found, but some or all event logs could not be found. Unreachable Logs: Security.

So, I found that this is because of windows 7 and some new security. Therefore, right now I have to grant .exe administrator rights.

Is there any way around this so that it does not need administrator rights? I don’t know if people will feel too good if they have to constantly run my application with administrator rights.

I plan to put this later on a Windows 2008 machine, so I assume that it will suffer from the same problem.

+6
c # windows-7 windows-server-2008 event-log
source share
2 answers

You can create an event source at the installation point to make this choice once. Once the source is created in the registry, you can add events to it without the need for administrator rights.

Like the CreateEventSource function, there is also an EventLogInstaller class:

http://msdn.microsoft.com/en-us/library/system.diagnostics.eventloginstaller.aspx

WiX also offers this functionality in it. Extension Utility:

How to create an event log source using WiX

+3
source share

NETWORK SERVICE OR Impersonator User must have read / write access to HKEY_LOCAL_MACHINE \ SYSTEM \ CurrentControlSet \ Services \ EventLog \ Security

+1
source share

All Articles