Click here to Skip to main content
16,015,973 members
Articles / Web Development / IIS
Article

Event Log RSS Feed Generator

Rate me:
Please Sign up or sign in to vote.
4.33/5 (35 votes)
30 Jun 20053 min read 221.2K   1.3K   64   35
A simple utility to provide remote, organized access to the system Event Log messages.

Introduction

How many times did you need to check the Event Log of your production web server but since you do not have permission to log on to that server, you had to wait for the administrator or webmaster to be available and open the Event Viewer for you?

In my experience, that happens very often. Often enough to let me think twice before writing code that logs messages to the Event Log. Unfortunately (or fortunately), the Event Log is still a very reliable place to log diagnostic messages, and even if we log to a custom database infrastructure, there's the chance that that database becomes unavailable and we need a fallback plan. The Event Log is usually a good last resort place to log important messages. Aside of that, many other applications and services already log their errors and warnings in the Event Log, so we will always be coming back to it at a point or another.

What is desirable here is a more flexible way to access the Event Log. More flexible but not less safe. We also need to protect our system messages from prying eyes.

Enter the RSS Feed Generator

With this goal in mind, I wrote a very simple utility to produce RSS feeds from the Event Logs in any system that has IIS with ASP.NET 1.x installed.

The utility is comprised of a single ASP.NET webform without code behind. This single .aspx file accepts querystring parameters that enables you to better specify how many and what kind of messages you are interested in.

Using the code

To get this utility going, all you need to do is unzip the accompanying .zip file and place the files GetLog.aspx and rssToTable.xsl in any existing or new ASP.NET application virtual folder. After the files are there, you'll have access to the RSS XML just by browsing to it, like:

http://yourserver/thefolder/GetLog.aspx

If your browser is XSLT-capable (like IE), the produced XML will be formatted in HTML automatically to help you find the information you are looking for.

The above URL will return, by default, the last 25 entries in the Application Event Log. You can change the number of returned entries using the top parameter, like:

http://yourserver/thefolder/GetLog.aspx?top=40

You can change the desired event log using the log parameter, like:

http://yourserver/thefolder/GetLog.aspx?log=YourLog

Note: The System and Security logs are programmatically blocked to prevent access to critical information.

You can filter on specific types of messages using the types parameter, like:

http://yourserver/thefolder/GetLog.aspx?GetLog.aspx?types=error,warning

As you can see, this parameter is a comma delimited list of event log message types. The available types are Information, Warning, Error, SuccessAudit, and FailureAudit, but you are likely to be more interested in the first three types.

You can restrict the desired message source using the source parameter, like:

http://yourserver/thefolder/GetLog.aspx?source=MSSQLSERVER

To get even more interesting filtering, you can combine any of the above parameters to get closer to messages you are watching for:

http://yourserver/thefolder/GetLog.aspx?GetLog.aspx?
   top=40&types=error&log=MyLog&source=MyApplication

Security Notes

Event Log messages often contain precious information that should not fall in the wrong hands. When you deploy this utility in any of your servers, be careful not to make it accessible by those who shouldn't be reading these messages.

Configure the ASP.NET application folder that contains the file to not be accessible without proper authentication, or to only be accessible through an internal IP address or some other scheme that protects your messages.

RSS Feed Aggregators

This utility combined with a decent RSS aggregator of your liking can provide you a collection of subscribed feeds that will allow you to keep an eye on your applications and search for diagnostic messages when some error occurs.

History

  • June 27th 2005 - Following suggestions in the comments, changed the GUID format and the HTTP error code returned in case of a forbidden query. Added an XSLT transformation to the raw output, to make the display prettier in the browser.
  • May 25th 2005 - Code submitted.

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


Written By
United States United States
Sergio Pereira is a senior software developer and architect. He currently makes his services available throughout Chicago and suburbs. Sergio has always made himself proficient in mainstream Microsoft technologies and has a deep interest in emerging technologies and the software life cycle aspect of development.
Feel free to contact Sergio at sergio_pereira(AT)msn(dot)com.

Comments and Discussions

 
GeneralRe: Does only work on english windows Pin
Sergio Pereira17-Jul-05 8:18
Sergio Pereira17-Jul-05 8:18 
GeneralRe: Does only work on english windows Pin
Radeldudel17-Jul-05 21:06
Radeldudel17-Jul-05 21:06 
GeneralSystem Event Log Pin
Chris Marts28-Jun-05 5:13
Chris Marts28-Jun-05 5:13 
GeneralRe: System Event Log Pin
Sergio Pereira28-Jun-05 6:17
Sergio Pereira28-Jun-05 6:17 
GeneralRe: System Event Log Pin
Chris Marts28-Jun-05 6:22
Chris Marts28-Jun-05 6:22 
GeneralNo more waiting for webmaster Pin
AndyGarcia31-May-05 5:53
AndyGarcia31-May-05 5:53 
GeneralRSS Validation Pin
JoelDKraft27-May-05 17:55
JoelDKraft27-May-05 17:55 
GeneralRe: RSS Validation Pin
Sergio Pereira28-May-05 5:13
Sergio Pereira28-May-05 5:13 
GeneralCOOL Pin
eggie527-May-05 4:00
eggie527-May-05 4:00 
GeneralRe: COOL Pin
Chris Richner27-May-05 4:15
Chris Richner27-May-05 4:15 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.