Reading event log – Only exception part

Posted on October 20 2009 by Sachin Jain

Here is the few line code

try
{
int intCount = 1;
EventLog EventLog1 = new EventLog();
EventLog1.Log = “Application”;

//EventLog1.MachineName = “SERVER1″;
int intLatestIndex = EventLog1.Entries.Count;

int idx = EventLog1.Entries[intLatestIndex - 1].Message.IndexOf(”Exception information”);

Response.Write(EventLog1.Entries[intLatestIndex - 1].Message.Substring(idx).Replace(”\n”, “
“));
intCount++;
}
catch (Exception exp)
{
}

VN:F [1.7.7_1013]
Rating: 0.0/5 (0 votes cast)
VN:F [1.7.7_1013]
Rating: 0 (from 0 votes)

Leave a Reply

Get Adobe Flash playerPlugin by wpburn.com wordpress themes

Powered by Sachin Jain