T
timb
Hi,
does any have any sample code of the above?
i have tried the example from the help but am unable to get my windows
service to create a new logfile and start logging to it.
I am able to create one however if my application is a windows form
application.
Thanks in advance
TimB
public UserService2()
{
this.AutoLog = false;
// create an event source, specifying the name of a log that
// does not currently exist to create a new, custom log
if (!System.Diagnostics.EventLog.SourceExists("MySource"))
{
System.Diagnostics.EventLog.CreateEventSource(
"MySource","MyLog");
}
// configure the event log instance to use this source name
eventLog1.Source = "MySource";
}
protected override void OnStart(string[] args)
{
// write an entry to the log
eventLog1.WriteEntry("In OnStart.");
}
does any have any sample code of the above?
i have tried the example from the help but am unable to get my windows
service to create a new logfile and start logging to it.
I am able to create one however if my application is a windows form
application.
Thanks in advance
TimB
public UserService2()
{
this.AutoLog = false;
// create an event source, specifying the name of a log that
// does not currently exist to create a new, custom log
if (!System.Diagnostics.EventLog.SourceExists("MySource"))
{
System.Diagnostics.EventLog.CreateEventSource(
"MySource","MyLog");
}
// configure the event log instance to use this source name
eventLog1.Source = "MySource";
}
protected override void OnStart(string[] args)
{
// write an entry to the log
eventLog1.WriteEntry("In OnStart.");
}