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 Robert Pepersack <rp...@mdinsurance.state.md.us> on 2004/04/21 14:42:06 UTC
Exception Quandry
Hello.
I have an exception that wraps other exceptions. I would like to log my
own message and the message from the original exception's getMessage()
method. I also want to log a system-generated exception ID that is created
in the constructor of my wrapper exception. I want the log message and my
wrapper exception's message to include the class and method name of where
the message was logged. So, my exception needs information from log4j, and
log4j needs information from my exception. Also, I have a class that
converts SQLException into my own (more specifiic) exceptions by examining
the error code inside SQLException.
The book has a chapter on MDC and NDC, but the information in the
diagnostic contexts applies to a thread, not to a specific exception. I've
also considered using Ceki's Logger wrapper, but I'm wondering if there is
a way to do this without extending log4j (although I'm very willing to
extend log4j, if necessary).
Also, I read in the book that the %M (along with %C, %F, %l, and %L) "can
be excruciatingly slow." Does anyone know of a better way to get the
method name of the calling class? Is using a rendered object that contains
the method name a good idea?
I've tried all of this a few ways, but none of them are elegant. Does
anyone have any ideas?
Thanks,
Bob
---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org