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()
Console.WriteLine("Wrote starting...........")
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


Simplified Development efforts


Two aspects of creating Web-based applications present unique challenges to web developers: Visual page design and debugging application. Visual page design is straightforward when creating static content; however when you need to present the result of executing a query in a tabular format using ASP page, page design can get rather involved. This is because developers need to mix traditional Asp code, which represent the application’s logic and HTML, which represent the presentation of data. ASP.NET and .NET framework simply development by allowing developers to separate an applications logic from its presentation. Resulting in an easier to maintain code base. Asp.NET can also handle the details of maintaining state of controls, such as the contents of textboxes between calls to the same Asp page, therefore reducing the amount of code you need to write. Visual Studio .NET which is tightly integrated with .NET framework, assist developers as they create ASP.NET and other applications by providing visual designers that facilitate visual drag and drop editing making page layout and form layout a breeze.

Another aspect of creating applications is debugging. Developers sometimes make mistakes; Systems don’t behave as you expect them to and unexpected conditions arise-all of these issues are collectively referred to as, using the affectionate term ‘bugs’ tracking down bugs known as debugging. Developers must be familiar with variety of debugging tools sometimes available from third party, and techniques- A combination of programming techniques for using a particular tool. The .NET framework simplifies debugging with support for runtime diagnostics.

Runtime diagnostics not only help you track down bugs but also help you determine how will your applications perform and assess the condition of your application. The .NET framework provides three types of Runtime diagnostics

1. Event Logging

2. Performance Counter

3. Tracing