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 »

System Event Log Manager


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



System Event Log Manager



The following code will explain you how to handle the system Event log.
It will show how to write the event log and how to get the event log.

Name Space part


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


In the above namespaces using System.Diagnostics is used for event log.

Create an Event log.
We can create the event log by using the class EventLog.
MyEventLog.WriteEntry has the following options

Syntax:

EventLog.WriteEntry(Registered event source,Event entry message, Event type ,Application-specific ID,Application-specific category, Event data );


The follosing code is used to create an event log

EventLog MyEventLog = new EventLog();
MyEventLog.log = "Application";
MyEventLog.Source = "www.Dotnetspider.com";
MyEventLog.WriteEntry("The member enterd into the webpage");



We can get the Event log entries by using the following code
The following code will display 100 events in the log

for(int i = 0; i < 100; i++)
{
Console.WriteLine(MyEventLog.Entries[i].Message)
Console.WriteLine(MyEventLog.Entries[i].MachineName)
Console.WriteLine(MyEventLog.Entries[i].Source)
Console.WriteLine(MyEventLog.Entries[i].TimeWritten)
}


The following code is used to close the event log.

MyEventLog.Close();


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.
System Event Log Manager  .  System Event Log  .  Manager  .  Event log processing using C#.NET  .  Event Log  .  Create event log using C#  .  

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: Display top 10 entries from the Event log
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