C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Resources » Code Snippets » Operating System »

Display top 10 entries from the Event log


Posted Date: 03 Sep 2009    Resource Type: Code Snippets    Category: Operating System
Author: Shunmuganathan MMember Level: Diamond    
Rating: 1 out of 5Points: 10



Description :


We can get top 10 entries from the event log by using
the following code.

The name space using System.Diagnostics takes important part in this
requirement

Name Space Part

using System;
using System.Resources;
using System.Drawing;
using System.Collections;
using System.Windows.Forms;
using System.Diagnostics;
using Microsoft.Win32;
using System.Resources;



Coding Part

class MyEventLogClass
{
static void Main(string[] args)
{
EventLog MyEventLog = new EventLog();
MyEventLog.Log = "Application";
MyEventLog.Source = "www.Dotnetspider.com";
MyEventLog.WriteEntry("Testing message");

for(int count = 0; count < 10; count++)
{
Console.WriteLine("Message: " + MyEventLog.Entries[count].Message );
Console.WriteLine("Machine: " + MyEventLog.Entries[count].MachineName );
Console.WriteLine("Sounce : " + MyEventLog.Entries[count].Source );
Console.WriteLine("Time : " + MyEventLog.Entries[count].TimeWritten);

}
MyEventLog.Close();
}
}


Code Explanation

1. Create the instance of the Eventlog.
2. By using the for loop we can get the entries
3. get the events from that entry

By
Nathan



Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sign In to add tags.
Event log  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: user32.dll message box
Previous Resource: System Event Log Manager
Return to Discussion Resource Index
Post New Resource
Category: Operating System


Post resources and earn money!
 
More Resources



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use