Handing the exception and logging is very important requirement of any application. There are different options to achieve this but the one which I have used mostly is Microsoft Enterprise Exception Handling and Logging Library. It’s very handy and easy to use. We can store the exceptions details in various formats like text, XML file or system event log.
Now in case when we store exceptions in the system event log, we need to construct viewer page where admin user can see the exceptions thrown in the application and pass that information to the development team. Here we need to fetch exception log details from the system event log of server.
To achieve this there is inbuilt method EventLog.GetEventLogs available in the C# but if we have thousands of events on the system event log then it will take significant amount of time to fetch event log detail. To avoid the performance issue, It is advisable to use EventLogQuery and EventLogReader classes to fetch only small set of event logs based on the filter criteria like Source, Datetime etc..
Refer following article for more technical details on how to implement this approach.