windows service with its own event log

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 ?
 
B

Bennie Haelen

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top