Open source
Error Handler project
When a web application fails in front of a real visitor, you need the details on disk and easy to search. ErrorHandler does that job and nothing more.
The problem it solves
Unhandled exceptions in a live web application are invisible unless you happen to be watching. Building your own logging table and viewer takes a day you would rather spend on features. ErrorHandler is the shortcut: a small library that writes the exception to a table, and a viewer that reads the table back.
Two pieces of software
- The logging library. A class library that exposes a single method,
saveError, which your catch block calls with the details of the failure. - The viewer site. A small web application that searches and displays the rows that were written, using either a quick view of recent entries or a custom search.
What the saveError method records
The method takes the connection string and the error message as required values, then optional extras: the time, the stack trace, the location in your code, the visitor address and the server name. Five spare fields are left open for anything specific to your application. It returns the new row identifier, which is useful to show a visitor so they can quote it when they call support.
| Parameter | Required | Purpose |
|---|---|---|
| Connection string | Yes | Points at the database holding the error table |
| Error message | Yes | The text of the exception |
| Time | Yes | When the failure happened |
| Stack trace | No | Where in the code it happened |
| Location | No | Module or page that raised it |
| Visitor address | No | Who hit the failure |
| Server name | No | Which machine served the request |
| Five custom fields | No | Anything specific to your application |
Setting it up
- Create the error table in a SQL Server database, either by running the supplied script or by restoring the supplied backup.
- Run the small test site to confirm the library can connect and write a row.
- Point the viewer site at the same database and confirm the rows appear.
- Reference the library from your own project and call
saveErrorinside your catch blocks.
Searching the log
The viewer offers a quick view of the most recent entries, a view of everything from the last week, and a custom search across error identifier, message and a date range. You can match exactly or match a prefix, choose newest first or oldest first, and set how many rows come back.
Using it on more than one application
Give each application its own error table and its own instance of the viewer. That keeps one busy application from drowning out the errors of another.
Licence
The project is released as open source so you can adapt it. Read the licence agreement before you redistribute it, and share it with anyone who finds it useful.