When we host an ASP.NET application in a shared web host and in similar cases, we would not be in a position to use EventViewer to view System EventLogs. In these cases, we can use a simple ASP.NET page which will read all System Logs and display it page by page in the web browser.
The Modus Operandi
.NET provides a rich class library to browse EventLogs in the system in a very easy to use fashion. We can make use of these to read the logs and display the same. Developers who begin in C#/.NET can learn easily how to use System EventLogs to record information, classify and read them.
Here is a sample screenshot of an EventLog and the columns of significance being read and paginated on the web browser.
- Expand this application to accommodate viewing of EventLogs in other systems. The API does support this but from within the realm of ASP.NET, security exceptions might occur, since ASP.NET Worker process would not have network privileges.
- Sorting of important columns.
- Search feature to locate the information that we desire in the shortest possible time.
- To backup the EventLog to view in the local system. We have this feature in EventViewer of Control Panel which saves the files as .EVT. This API needs to be explored and implemented.
- Currently, I have zipped only the necessary files and hence to view it, a manual process of unpacking into an existing web folder and a build is required.
I think for a beginner in C#, this article should present enough insight into easy-to-use logging mechanisms and how to use them to debug and maintain their applications.