You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4net-user@logging.apache.org by Ron Grabowski <ro...@yahoo.com> on 2005/01/06 01:00:10 UTC

Best practices to avoid logging same information multiple times

I'm currently logging exceptions as soon as they occur. If an exception
occurs in my data layer, I log it in the catch block of the try it
occured. Should that exception also be caught at the very top layer
that initiated the exception (i.e. the btnSubmit_Click event that
started the form processing)? 

After seeing all the logging that comes out of frameworks like the
Struts Framework for Java and data access libraries like iBatis (in the
Java version at least, iBatis.NET doesn't log nearly as much) I find
myself wanting to log as much as I can whenever I can. Being able to
trace through and find exactly what went wrong has saved me countless
hours of guess work. 

On one hand I welcome more logs but on the other hand I don't want to
get carried away with having to decipher why there are two (or more)
log entries for all my exceptions. I'm paranoid that if I wait to catch
an exception at the top most level I risk the chance of missing it or
poluting the stack trace with a lot of unnecessary information. During
development I'm finding that I often have a logger for each layer of my
application.

How is the rest of the list handling things?

- Ron