Main Menu

jPCT

Started by cyberkilla, January 31, 2007, 01:55:52 PM

Previous topic - Next topic

cyberkilla

Egon, I use this piece of code to add an entire stack trace to the logs.

Perhaps you can find use for it in the official logger.


public static String getStackTrace(Throwable aThrowable)
{
   final Writer result           = new StringWriter();
   final PrintWriter printWriter = new PrintWriter(result);
   
   aThrowable.printStackTrace(printWriter);
   return result.toString();
}

To use this, I have a Logger.addError(Throwable e) method.
It just turns the stack trace into a string.

I cannot use the official logger, because I already had my own.


It is very useful for me, so I thought I'd share it.
http://futurerp.net - Text Based MMORPG
http://beta.rpwar.com - 3D Isometric MMORPG