Windows Service - Event Log
- From: pisquem@xxxxxxxxxxx
- Date: 27 Jun 2006 11:46:39 -0700
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.");
.
- Follow-Ups:
- Re: Windows Service - Event Log
- From: Willy Denoyette [MVP]
- Re: Windows Service - Event Log
- From: Tim Van Wassenhove
- Re: Windows Service - Event Log
- From: Kevin Spencer
- Re: Windows Service - Event Log
- From: Ignacio Machin \( .NET/ C# MVP \)
- Re: Windows Service - Event Log
- From: Bill Schmidt
- Re: Windows Service - Event Log
- Prev by Date: Re: Collection with Key and Index
- Next by Date: Re: port 80
- Previous by thread: Re: Generics with List and Delegates?
- Next by thread: Re: Windows Service - Event Log
- Index(es):
Relevant Pages
|