The other appenders check layout.ignoresThrowable() before writing the stack trace. SyslogAppender does not. As a workaround, I'm having to extend SyslogAppender, capture LoggingEvent and create a new LoggingEvent without the stack trace. Searching for: ignoresThrowable src\java\org\apache\log4j\WriterAppender.java(294): if(layout.ignoresThrowable()) { src\java\org\apache\log4j\net\SMTPAppender.java(220): if(layout.ignoresThrowable()) { src\java\org\apache\log4j\net\TelnetAppender.java(90): if(layout.ignoresThrowable()) { src\java\org\apache\log4j\nt\NTEventLogAppender.java(103): if(layout.ignoresThrowable()) {
I just went ahead and used your SyslogAppender code, but fixed the bug and put it in my own package until it gets fixed in Log4J.
1.2.12 candidate
Please Note that other appenders check for ignoresThrowable() but they does not realy ignores, for example PatternLayout ignoresThrowable() returns true and java doc says "The PatternLayout does not handle the throwable contained within LoggingEvents. Thus, it returns true" but appenders print stack trace. So Line in all above mentioned appenders: if(layout.ignoresThrowable()) { should be modified to if(!layout.ignoresThrowable()) { in order to prevent stack trace printing if it is ignored from layout Workaround to this problem is just extend appropriate layout, override ignoresThrowable() method, return true if stack trace must be printed and return false if not and finally use this layout in your log4j config.
Brought SyslogAppender in line with all the other appenders and now checks the ignoresThrowable() method. However, all this does is just control whether the appender outputs the throwable (true) or lets the layout handle it (false). If you truly do not want the throwable ever output, then you need to override the layout to return false for ignoresThrowable and to then do nothing with the throwable when it creates the output. Looking at the cvs head version of SyslogAppender, there were a number of changes to make it RFC 3164 compatible, one of the changes to completely remove the output of throwables (assuming the layout doesn't do it).