You must render the stack trace to a string buffer and then emit the string to the PrintStream in a single println:
public void printStackTrace(PrintStream s) { StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); pw.println(this); StackTraceElement[] trace = getOurStackTrace(); for (int i = 0; i < trace.length; i++) pw.println("\tat " + trace[i]); Throwable ourCause = getCause(); if (ourCause != null) ourCause.printStackTraceAsCause(pw, trace); synchronized (s) { s.println(sw.toString()); } } xxxxxxxxxxxxxxxxxxxxxxxx Scott Stark Chief Technology Officer JBoss Group, LLC xxxxxxxxxxxxxxxxxxxxxxxx -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Vladyslav Kosulin Sent: Friday, January 30, 2004 12:32 PM To: [EMAIL PROTECTED] Subject: Re: [JBoss-user] log4j SMTP appender trouble Scott M Stark wrote: > It depends on what is generating the stack trace. In order to get this > behavior there has to be a line by line emission of the stack trace > using System.err.println() for each line rather than one > System.err.println() > with the entire stack trace as a message. What is the source of this? You are right: I use e.printStackTrace(), and here is the code from Throwable.java: public void printStackTrace(PrintStream s) { synchronized (s) { s.println(this); StackTraceElement[] trace = getOurStackTrace(); for (int i=0; i < trace.length; i++) s.println("\tat " + trace[i]); Throwable ourCause = getCause(); if (ourCause != null) ourCause.printStackTraceAsCause(s, trace); } println for class name and message, println for every entry. Any ideas how to cut the corner here? Vlad ------------------------------------------------------- The SF.Net email is sponsored by EclipseCon 2004 Premiere Conference on Open Tools Development and Integration See the breadth of Eclipse activity. February 3-5 in Anaheim, CA. http://www.eclipsecon.org/osdn _______________________________________________ JBoss-user mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jboss-user