Windows Service - Event Log



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.");

.



Relevant Pages

  • Re: Error tracking a windows service
    ... Catch block I log any exceptions to the Event Log ... | arguement to tell it to do something special like capture ... | when certain command line arguements are passed in, the compiled code ... | that with a windows service? ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Windows Service - Event Log
    ... Check your service account, only admin accounts have the right to "create" ... |I am building an windows service that is to be deployed on a windows ... Create an EventLog instance and assign its source. ... Write an informational entry to the event log. ...
    (microsoft.public.dotnet.languages.csharp)
  • Office SP2 update causes Excel automation crash!
    ... A client's server was automatically updated to MS Office 2003 SP2 at 3am ... but a Windows Service that I ... crashing everytime it tries to open (via automation) a spreadsheet. ... The Event Log says first, "Rejected Safe Mode action: ...
    (microsoft.public.excel.programming)
  • How do I grant permissions to my .NET 2.0 program in Windows 2003?
    ... I created an application under C# that runs as a Windows Service. ... write an event to the Windows event log to check in, ... record in a SQL server database, ...
    (microsoft.public.dotnet.framework)
  • intermittent net 2.0 runtime error, faulting module kernel32.dll
    ... windows service that is installed on a server. ... business logic that runs 24x7 is within a try/catch statement. ... the system event log shows the windows service unexpectedly stopping within ...
    (microsoft.public.dotnet.framework.aspnet)