What’s the best way to manage error logging for exceptions

errorsexceptionsissue-trackinglogging

Introduction

If an error occurs on a website or system, it is of course useful to log it, and show the user a polite message with a reference code for the error.

And if you have lots of systems, you don't want this information dotted around – it is good to have a single centralised place for it.

At the simplest level, all that's needed is an incrementing id and a serialized dump of the error details. (And possibly the "centralised place" being an email inbox.)

At the other end of the spectrum is perhaps a fully normalised database that also allows you to press a button and see a graph of errors per day, or identifying what the most common type of error on system X is, whether server A has more database connection errors than server B, and so on.

What I'm referring to here is logging code-level errors/exceptions by a remote system – not "human-based" issue tracking, such as done with Jira,Trac,etc.

Questions

I'm looking for thoughts from developers who have used this type of system, specifically with regards to:

  • What are essential features you couldn't do without?
  • What are good to have features that really save you time?
  • What features might seem a good idea, but aren't actually that useful?

For example, I'd say a "show duplicates" function that identifies multiple occurrence of an error (without worrying about 'unimportant' details that might differ) is pretty essential.
A button to "create an issue in [Jira/etc] for this error" sounds like a good time-saver.

Just to re-iterate, what I'm after is practical experiences from people that have used such systems, preferably backed-up with why a feature is awesome/terrible.
(If you're going to theorise anyway, at the very least mark your answer as such.)

Best Answer

I have been in a project where with logged client errors using Microsoft Enterprise library. All exception where send to our mail box. In the mail subject we added hash code of serialized error for avoiding duplicated messages. One could of course store serialized messages in database and so on.

I recommend you to check out Microsoft Enterprise library and Log4Net.

Some Features of Log4Net

  • Support for multiple frameworks
  • Output to multiple logging targets
  • Hierarchical logging architecture
  • XML Configuration
  • Dynamic Configuration
  • Logging Context
  • Proven architecture
  • Modular and extensible design • High performance with flexibility
Related Topic