That will cut down on code duplication.
I'm surprised that the standard and defacto standard logging APIs don't
include the stacktrace. I thought there'd be one out there that did this.
> That will cut down on code duplication.
>
> I'm surprised that the standard and defacto standard logging APIs don't
> include the stacktrace. I thought there'd be one out there that did
> this.
If you look at the Log4J API docs you will see that each of the trace,
debug, info, warn, error and fatal methods are overloaded with a version
that takes two parameters, the second parameter being a Throwable. These
overloaded methods will output the stack trace from that Throwable along
with the message that you pass in the first parameter.
Dan.

Signature
Daniel Dyer
http://www.dandyer.co.uk
Patrick May - 17 Jan 2006 21:33 GMT
> > I'm surprised that the standard and defacto standard logging APIs
> > don't include the stacktrace. I thought there'd be one out there
[quoted text clipped - 6 lines]
> from that Throwable along with the message that you pass in the
> first parameter.
The java.util.logging.Logger class has this capability as well if
you use the log(Level,String,Throwable) method instead of the
convenience methods.
Regards,
Patrick
------------------------------------------------------------------------
S P Engineering, Inc. | The experts in large scale distributed OO
| systems design and implementation.
pjm@spe.com | (C++, Java, Common Lisp, Jini, CORBA, UML)
Dean Schulze - 18 Jan 2006 00:16 GMT
That worked. Thanks.
I knew I had seen stack traces in .log files, but their API isn't very
intuitive.
>> That will cut down on code duplication.
>>
[quoted text clipped - 10 lines]
>
> Dan.