A few thoughts -

-- Ceki never recommends extending logger, he recommends wrapping it with
the Decorator pattern.  Important distinction.
-- Consider a GUID as your unique identifier, and if subsequent exceptions
are "chained" then don't generate a new number, use the incoming exception's
unique id.  This is how my organization accomplished this and it's worked
pretty well thus far.  Also JVM's can create a unique ID for you, but I
forget what the API is, you'll have to search for it.
-- I don't know a way around the performance penalty (which doesn't mean
there isn't any), you could turn off those fields in normal operation and
turn them on when you need them.  You could also use Aspects (search for
AspectJ) to inject the necessary code to hard-code the values and pass them
to Log4j (this is kind of a lame solution in my opinion, but I'll throw it
out there).  Also remember that logging should primarily occur in
exceptional conditions, so unless your users are "misusing" logging I don't
know how utterly significant the performance hit is.  The most important
performance consideration with logging is when you've got a lot of tracing
calls and most of them are turned off most of the time.  The system needs to
realize this very quickly, as Log4j does.

Mike


-----Original Message-----
From: Robert Pepersack [mailto:[EMAIL PROTECTED]
Sent: Wednesday, April 21, 2004 8:42 AM
To: [EMAIL PROTECTED]
Subject: 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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

-------------------------------------------------------------------------------
This message and any included attachments are from Siemens Medical Solutions 
USA, Inc. and are intended only for the addressee(s).  
The information contained herein may include trade secrets or privileged or 
otherwise confidential information.  Unauthorized review, forwarding, printing, 
copying, distributing, or using such information is strictly prohibited and may 
be unlawful.  If you received this message in error, or have reason to believe 
you are not authorized to receive it, please promptly delete this message and 
notify the sender by e-mail with a copy to [EMAIL PROTECTED] 

Thank you

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to