jyothsna1803
asked on
Windows service Event Log implementation
Hi,
I am using .Net 2005 to write Windows service. I would like to implement Eventlog feature. I want to create my own event Log and write events on that log. I know in .Net 2003
Usually i have written code in the constructor. But i don't see any default constructor in .net 2005. What is the best place to write this code in .net 2005.
I don't want to see any design time errors.
public Service1()
{
this.GetConfiguration();
// This call is required by the Windows.Forms Component Designer.
InitializeComponent();
if (!System.Diagnostics.Event Log.Source Exists("Ev entSource" ))
{
System.Diagnostics.EventLo g.CreateEv entSource(
"EventSource","NewEventLog ");
}
eventLog1.Source = "EventSource";
eventLog1.Log = "NewEventLog";
// TODO: Add any initialization after the InitComponent call
}
I am using .Net 2005 to write Windows service. I would like to implement Eventlog feature. I want to create my own event Log and write events on that log. I know in .Net 2003
Usually i have written code in the constructor. But i don't see any default constructor in .net 2005. What is the best place to write this code in .net 2005.
I don't want to see any design time errors.
public Service1()
{
this.GetConfiguration();
// This call is required by the Windows.Forms Component Designer.
InitializeComponent();
if (!System.Diagnostics.Event
{
System.Diagnostics.EventLo
"EventSource","NewEventLog
}
eventLog1.Source = "EventSource";
eventLog1.Log = "NewEventLog";
// TODO: Add any initialization after the InitComponent call
}
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.