Create Window service project in C# - Part 2 (View event logs)

This article series describes about creation of windows service application using C#.net. My previous post describe about the creation and installing of the windows service using C#. This article will introduce you to the way to check logs on windows system.

Can you can remember, we create an event log for our windows service project. But where should I look for these logs to view those. This article will answer for that question.

You can check whether our new windows service is installed or not from Computer management and also you can start you service from here by clicking on "start". As we write on our program there is a action when starting the service to write "MyService started" on event log. (in OnStart method)

You can check these logs using either Visual studio or event viewer on windows.

Visual studio

Just open Server Explorer from visual studio to view all services. If you unable to find the server explorer, you can select it from view menu. (Or press Ctrl+W then L in VS 2010). You will find your event log under Servers --> [Your PC name] --> Event logs. When you expand your event log you will see all the logs which are loged by your service. (nor Refresh the list)



Event Viewer
Just open "Event viewer" from start menu and you will find your event log and its details. Also you can clear your logs from here.


2 comments: