Tuesday, May 6, 2008

Event logging

Event Logging

Windows 2000 and Windows XP have an important feature called Event Log a database containing important information about hardware and software events. The event log is useful for recording information about the status of your applications and provides system administrators a means of diagonosing problems, Since they can review event log entries using the event viewer(supplied with Windows and available in administrative tools group in the control panel). There are three types of event log events:

Informational Events

Usualy Contains information, such as an application starting or shutting down.

Warning Events


Usally provides information about unusual conditions that have the potential to become errors.

Error Events

Represent critical errors in an application that prevent it from executing normally.

Event are stored in Event logs - Windows supports three types of event logs

Application: Contains messages that applications such as Microsoft SQL Server.

System: Contains messages that device drivers and system service log.

Security: Contains system generated message about events that occur whwn security auditing is emabled

The .NET framework makes it easy to work with event log as shown in the following code

Imports System;
Imports System.Diagnostics;

Module eventLogDemo

Sub Mail()

IF Not EventLog.SourceExists("AspnetBible") Then
EventLog.CreateEventSource(("AspnetBible" , "Application")
Console.WriteLine("Created New Event Source 'ASPnetBible'")
End If

Dim evLog As New EventLog()
evLog.Source="ASPnetBible"
evLog.WriteEntry("...........Starting")
Console.WriteLine("Wrote starting...........")
evLog.WriteEntry("...........Exiting")
End Sub

End Module

The code is a Visual Basic .NET console application that creates an event souce
called ASPnetBible and write information about application stating and exiting events to the system's application event log


GOD BLESS YOU

2 comments:

Anonymous said...

Hai i was in search of what is event log is you have described about event logging in detail thank you for your help

Anonymous said...

nicely describes about event logging in .Net framework is nice article