Windows services cannot write log.

  • Thread starter Thread starter Theewara Vorakosit
  • Start date Start date
T

Theewara Vorakosit

Hi,

I try to write event log from my Windows service, which is c#. In OnStart
method I write a message to event log. I create event log object by using
Event Log Component. I set source and log property to "RMS" and "RMS",
respectively. I also put the following lines to the class constructor below
InitializeComponent, generated from VS.NET 2003) method.

if (!System.Diagnostics.EventLog.SourceExists("RMS"))
{
System.Diagnostics.EventLog.CreateEventSource(
"RMS","RMS");
}
eventLog.Source = "RMS";
eventLog.Log = "RMS";

When start, the exception is thrown.

Service cannot be started. System.ArgumentException: The source 'RMS' is not
registered in log 'RMS'. (It is registered in log 'Application'.) .....

So, how can I solve this?

Thanks,
Theewara
 
Back
Top