
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
458
|
Chapter 8: Diagnostics
code to run successfully, such as when the application is being installed or in a util-
ity run by an administrator. This should not be attempted as part of normal applica-
tion operations since it does require such a high level of access.
See Also
See the “Registry.LocalMachine Field” and “RegistryKey.Open Method” topics in
the MSDN documentation.
8.8 Searching Event Log Entries
Problem
Your application might have added many entries to the event log. To perform an
analysis of how the application operated, how many errors were encountered, and so
on, you need to be able to perform a search through all of the entries in an event log.
Unfortunately, there are no good built-in search mechanisms for event logs.
Solution
You will eventually have to sift through all the entries your application writes to an
event log in order to find the entries that allow you to perhaps fix a bug or improve
your application’s security system. Unfortunately, there are no good search mecha-
nisms for event logs. This recipe contains an
EventLogSearch class, to which you’ll
add static methods allowing you to search for entries in an event log based on vari-
ous criteria. In addition, this search mechanism allows complex searches involving
multiple criteria to be performed on an event