Note that the StackTraceElement class requires j2se
1.4+.
-Scott Heaberlin
--- Fergus Gallagher <[EMAIL PROTECTED]>
wrote:
> In special circumstances you might want each line of
> the stacktrace to be
> full log lines (i.e., with loglevel, MDC,
> threadname, etc). In this case you can
> use Throwable.getStackTrace() to get the individual
> line, and then do something like
>
> public static void logError(Logger log, Throwable
> ex, int limit) {
> if (log.isDebugEnabled()) {
> StackTraceElement[] ste =
> ex.getStackTrace();
> for (int i = 0; i < ste.length; i++)
> {
> if (i == limit) {
> return;
> }
> if (i==0) {
> log.debug(ste[i]);
> }
> else {
> log.debug("\t" +
> ste[i]);
> }
> }
> }
> }
>
>
>
> I use this when I need to see a stacktrace when I
> "grep" through the log
> file for a paricular thread, say.
=====
==============================
Scott Heaberlin
[EMAIL PROTECTED]
[EMAIL PROTECTED]
==============================
__________________________________
Do you Yahoo!?
The New Yahoo! Search - Faster. Easier. Bingo.
http://search.yahoo.com
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]