windows service with its own event log

  • Thread starter Thread starter John Grandy
  • Start date Start date
J

John Grandy

Unless I make the account under which my Windows Service runs a member of
local Administrators, I get startup failures if I include the following code
in the OnStart() event :

if(!EventLog.SourceExists("MyLog"))
{
EventLog.CreateEventSource("My Log", "Application");
}
EventLog appLog = new EventLog();
appLog.Source = eventSource;
appLog.WriteEntry("Test Log Entry",EventLogEntryType.Information);


Seems extreme to make a Service's credentials a member of local
Administrators ... any ideas ?
 
Hi John,

In order to create a new Event Source, you need to be a member of the
Administrators group. One workaround is to have a separate program that
creates the source for you, then you can run just this program from an
admin account, and your service can still run under "non-admin" credentials.

Regards,

Bennie Haelen
 
Back
Top