Click here to Skip to main content
Licence 
First Posted 23 Jul 2005
Views 42,986
Bookmarked 25 times

Mini Event Viewer in C#

By | 23 Jul 2005 | Article
A small and easy-to-use event viewer in C#.

Introduction

When we host an ASP.NET application in a shared web host and in similar cases, we would not be in a position to use EventViewer to view System EventLogs. In these cases, we can use a simple ASP.NET page which will read all System Logs and display it page by page in the web browser.

The Modus Operandi

.NET provides a rich class library to browse EventLogs in the system in a very easy to use fashion. We can make use of these to read the logs and display the same. Developers who begin in C#/.NET can learn easily how to use System EventLogs to record information, classify and read them.

Here is a sample screenshot of an EventLog and the columns of significance being read and paginated on the web browser.

Screenshot

Sample Image - EventViewerInCSharp.jpg

Features

  • Enumerates all the EventLogs in the Local System.
  • Enlists only the columns which we normally and mostly look up, so that we can locate the information that we desire in the shortest possible time and also quite easily.
  • Paginates the information, since EventLog will have large amount of information.
  • Easily reads and expands through all EventLogs in the System specified. The following enumeration achieves this trick:
    foreach (EventLog objEventLog in EventLog.GetEventLogs(whichmachine))
    {
        eventlogs.Items.Add(new ListItem(objEventLog.LogDisplayName, 
                                                    objEventLog.Log)
    }

TO-DO

  • Expand this application to accommodate viewing of EventLogs in other systems. The API does support this but from within the realm of ASP.NET, security exceptions might occur, since ASP.NET Worker process would not have network privileges.
  • Sorting of important columns.
  • Search feature to locate the information that we desire in the shortest possible time.
  • To backup the EventLog to view in the local system. We have this feature in EventViewer of Control Panel which saves the files as .EVT. This API needs to be explored and implemented.
  • Currently, I have zipped only the necessary files and hence to view it, a manual process of unpacking into an existing web folder and a build is required.

Summary

I think for a beginner in C#, this article should present enough insight into easy-to-use logging mechanisms and how to use them to debug and maintain their applications.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

Vasudevan Deepak Kumar

Web Developer

India India

Member

Vasudevan Deepak Kumar is from Chennai, India who has been in the programming career since 1994, when he was 15 years old. He has his Bachelors of Engineering (in Computer Science and Engineering) from Vellore Engineering College (now VIT University). He also has a MBA in Systems from Alagappa University, Karaikudi, India.


He started his programming career with GWBasic and then in his college was involved in developing programs in Fortran, Cobol, C++. He has been developing in Microsoft technologies like ASP, SQLServer 2000. For sometime, he has also been with PHP and MySQL based development in one of his previous organizations. Now currently his focus is on Microsoft .NET World (ASP.NET, C# and Whidbey)


In his past-time, he listens to polite Carnatic Music.

Web Presence


Homepage

http://www.lavanyadeepak.tk/

Blogs



Technical




Gossips



Spiritual







Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
-- There are no messages in this forum --
Permalink | Advertise | Privacy | Mobile
Web03 | 2.5.120517.1 | Last Updated 23 Jul 2005
Article Copyright 2005 by Vasudevan Deepak Kumar
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid