I highly doubt the newlines originate from anywhere else but the stringBuffer.append(this.layout.format(event));
call. The other four calls should not add any new lines. From your output example :
stringBuffer.append(largeIndent + stackTrace[i]); // -- is never called
stringBuffer.append(smallIndent); // -- won't add newline
stringBuffer.append("Caused by: "); // -- won't add newline (and not called)
stringBuffer.append(cause.toString()); // -- shouldn't add newline
By "shouldn't" I mean, any Throwable subclass can override the toString() method in order to append a \n at the end, but they generally don't and org.springframework.remoting.RemoteLookupFailureException
does not.
What Layout implementation does your class get initialized with? And how is that layout's format()
method implemented? Hopefully your IDE supports conditional breakpoints and you can stop the debugger after an append if stringBuffer.toString().contains("\n");