Bug 34026 - SyslogAppender.append() does not check layout.ignoresThrowable()
SyslogAppender.append() does not check layout.ignoresThrowable()
Status: RESOLVED FIXED
Product: Log4j
Classification: Unclassified
Component: Appender
1.2
All All
: P4 minor
: ---
Assigned To: log4j-dev
:
Depends on:
Blocks:
  Show dependency tree
 
Reported: 2005-03-15 23:48 UTC by John Smith
Modified: 2005-07-28 21:53 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description John Smith 2005-03-15 23:48:09 UTC
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()) {
Comment 1 John Smith 2005-03-16 05:54:32 UTC
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.
Comment 2 Mark Womack 2005-07-01 23:44:36 UTC
1.2.12 candidate
Comment 3 Andranik Movsisyan 2005-07-07 08:19:29 UTC
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.
Comment 4 Mark Womack 2005-07-29 05:53:44 UTC
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).