Windows services cannot write log.

  • Thread starter Theewara Vorakosit
  • 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
 

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