Re: Windows Service - Event Log
- From: "Willy Denoyette [MVP]" <willy.denoyette@xxxxxxxxxx>
- Date: Wed, 28 Jun 2006 09:17:45 +0200
Check your service account, only admin accounts have the right to "create"
private logs. If your service run with restricted privileges (which is
good), you'll need to create the log from another program, not from within
your service.
Willy.
<pisquem@xxxxxxxxxxx> wrote in message
news:1151433999.353419.127040@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|I am building an windows service that is to be deployed on a windows
| server 2003 and I want to have activity written to the event log, I
| want its own log called ('CustomLog')
|
| Below is what I have so far...its builds fine but when I go to start
| the service i get the following error.
|
| ---------------------------
| Services
| ---------------------------
| The CWindowService service on Local Computer started and then stopped.
| Some services stop automatically if they have no work to do, for
| example, the Performance Logs and Alerts service.
| ---------------------------
| OK
| ---------------------------
|
|
| What am I doing wrong? Right after this code I have this line....and it
| never had an issue.
| EventLog.WriteEntry("Refresh started successfully.");
|
| //1. Create the source, if it does not already exist.
| if (!EventLog.SourceExists("CustomLog"))
| {
| EventLog.CreateEventSource("CustomLog", "MyNewLog");
| }
|
|
| //2. Create an EventLog instance and assign its source.
| EventLog myLog = new EventLog();
| myLog.Source = "CustomLog";
|
|
| //3. Write an informational entry to the event log.
| myLog.WriteEntry("Writing to event log.");
|
.
- References:
- Windows Service - Event Log
- From: pisquem
- Windows Service - Event Log
- Prev by Date: Re: Windows Service - Event Log
- Next by Date: Re: XML documentation question
- Previous by thread: Re: Windows Service - Event Log
- Next by thread: Refressing ConfigurationSettings.AppSettings
- Index(es):
Relevant Pages
|
Loading