You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by Rob Cecil <rc...@sagestone.com> on 2003/05/05 16:16:59 UTC

Logging in the constructor of a custom exception class

Hi,

 

I am wondering if anyone has used a design pattern of creating a custom
exception class hierarchy, the root of which makes logging calls to
Log4j in the constructor?   In other words, instead of developers making
calls directly to the Logging API in catch() clauses, have them instead
throw a custom exception which logs the exception for the developer?

 

Is there any real benefit to having Exceptions log themselves?   Has
this pattern worked before?

 

Thanks in advance!

 

 

Rob Cecil