Handling Events and Logging Information from a Windows Service Application
Handling Events and Logging Information from a Windows Service Application
Rating:
A Windows service application supports various customized events, such as changing the power status of a computer or logging information. The logging information can change the state of the service or errors in the system event logs and customize your event logs. By using the performance counter, you can also monitor the performance of your service. The events of a Windows service totally depend on the state of the service. Whenever the state of service changes, the corresponding event occurs. For example, if your service changes from a running state to a pause state, then the pause event occurs. A Windows service supports four events, namely start, stop, pause, and continue.
With the occurrence of various events in your service application, you can log, in the event logs, the information that can track the state of your service. The various event-logging features include the failure of a service, low-memory condition, or passing of a service, which can then determine the type and cause of the error. The event log component is used to write log entries that can be accessed on both local and remote computers. The following are the three types of event logs available in your service application:
To access and create entries in the system application, the AutoLog property of the ServiceBase class should be set to true. When you install your service application, the installer checks the value of the AutoLog property, and if the value is set to true, your service application gets registered by the installer in the Application log. After that, whenever your service is started, stopped, paused, resumed, installed, or uninstalled, your service automatically logs information.

Rating:
Other articles
- What is application domain policy?
- How to use the UTF8Encoding class to encode and decode a text?
- What is the IOrderedDictionary interface?
- What is unboxing?
- Things to practice for Microsoft test 70-536.
