.NET Tip

Simplify finding the entry you need from an event log. Read on and learn more.



I frequently receive calls asking why an application is not behaving as expected. Many times, a quick look at the database can provide the answer. Sometimes, however, things are a little more involved. Our internal applications make extensive use of event logs. The event logs will contain error messages, warnings, and in the case of some occasionally connected systems a log of all the data received. Trying to manually forge through the event logs can be a daunting task. The answer, of course, is to let a computer do most of the searching for you. Here is a class with a couple static methods that you can use to quickly limit the number of event log entries that you have to manually search through:

public enum EventLogFilterType
{
TimeGenerated,
UserName,
MachineName,
Category,
Source,
EntryType,
Message,
EventID
}

public sealed class SearchEventLog
{
// Prevent this class from being instantiated.
private SearchEventLog() {}
public static EventLogEntry[]
FilterEventLog(EventLogFilterType FilterType,
IEnumerable Entries, object Criteria1,
object Criteria2)
{
ArrayList FilteredEntries = new ArrayList();
foreach (EventLogEntry Entry in Entries)
{
switch (FilterType)
{
case EventLogFilterType.TimeGenerated:...

Read the Rest of this Article at Developer.com

Rss   Delicious   Digg   Add To My Yahoo   Add To My Google   Bookmark   Search Plugin

Topics:
Architecture & Design Languages & Tools Project Management Web Services
Database Microsoft & .NET Security Wireless
Java Open Source Techniques XML