Link to home
Create AccountLog in
Avatar of jyothsna1803
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.EventLog.SourceExists("EventSource"))
                  {        
                        System.Diagnostics.EventLog.CreateEventSource(
                              "EventSource","NewEventLog");
                  }
                  eventLog1.Source = "EventSource";
                  eventLog1.Log = "NewEventLog";


                  // TODO: Add any initialization after the InitComponent call
            }
ASKER CERTIFIED SOLUTION
Avatar of Christopher Kile
Christopher Kile
Flag of United States of America image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer