Tuesday, July 10, 2012

Creating and Using EventLog in WindowService

First Drag and Drop EventLog component into Component design from ToolBox 

Event log (named : eventLog1) is added into you component class.

Create New Event Log in your window service Component class

 public EmployeeStatusService()
     if (!System.Diagnostics.EventLog.SourceExists("MyLogInfo"))
                    "MyLogInfo", "HirenLog");
     eventLog1.Source = "SmartNetDeviceInfo";
     eventLog1.Log = "SmartNetLog";

Write Log entry on created log

 protected override void OnStart(string[] args)
     eventLog1.WriteEntry("Service Started");

No comments:

Post a Comment