Summary: The SMTPAppender class does not output any newline characters between stack trace lines when appending the stack trace to the end of a mail message. Steps to reproduce: 1. Configure log4j.xml to use the SMTPAppender to send a message. 2. Run java code that will generate a log event that will be sent by the configured SMTPAppender. Expected results: The stack trace in the message should have newlines between stack trace lines: java.net.ConnectException: Connection refused: connect at java.net.PlainSocketImpl.socketConnect(Native Method) at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:305) at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:171) at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:158) at java.net.Socket.connect(Socket.java:452) at java.net.Socket.connect(Socket.java:402) at java.net.Socket.<init>(Socket.java:309) at java.net.Socket.<init>(Socket.java:124) Actual results: The stack trace in the message does NOT have newlines between stack trace lines (looks much worse when viewing in a mail client): java.net.ConnectException: Connection refused: connect at java.net.PlainSocketImpl.socketConnect(Native Method) at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:305) at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:171) at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:158) at java.net.Socket.connect(Socket.java:452) at java.net.Socket.connect(Socket.java:402) at java.net.Socket.<init>(Socket.java:309) at java.net.Socket.<init>(Socket.java:124) Regression: Tested on log4j-1.2.8 and log4j-1.2.13. Both of them exhibit the "actual behavior" documented above.
Created attachment 17705 [details] Patch v1 Patch v1 fixes the issue for me when log4j is built locally. Note that the email client I'm using happens to be MS Outlook XP (which makes interesting choices for where to put line breaks), but I still think the stack trace should have newlines after each line.
Not sure that it really should be Layout.LINE_SEP or '\n', but log4j 1.3 already had the problem fixed using LINE_SEP so stuck with that. Committed in log4j 1.2 branch in rev 439036.