Bug 40502

Summary: SyslogAppender assumes all lines start with tab
Product: Log4j - Now in Jira Reporter: Ian Reilly <iwreilly>
Component: AppenderAssignee: log4j-dev <log4j-dev>
Status: RESOLVED FIXED    
Severity: normal CC: kay.abendroth
Priority: P2    
Version: 1.2   
Target Milestone: ---   
Hardware: Other   
OS: other   

Description Ian Reilly 2006-09-13 20:07:27 UTC
The SyslogAppender assumes each line of output starts with a tab and replaces 
it with spaces.  If the line doesn't start with a tab, the first character of 
the line is lost.  If the line is empty, the appender will get an exception.

The patch to fix this problem is:

*** SyslogAppender.java.orig	Wed Sep 13 15:53:09 2006
--- SyslogAppender.java	Wed Sep 13 15:53:05 2006
***************
*** 260,266 ****
          if(len > 0) {
            sqw.write(s[0]);
            for(int i = 1; i < len; i++) {
!             sqw.write(TAB+s[i].substring(1));
            }
          }
        }
--- 260,274 ----
          if(len > 0) {
            sqw.write(s[0]);
            for(int i = 1; i < len; i++) {
!             if (s[i].length() > 0) {
!               if (s[i].charAt(0) == '\t') {
!                 sqw.write(TAB+s[i].substring(1));
!               } else {
!                 sqw.write(TAB+s[i]);
!               }
!             } else {
!               sqw.write(s[i]);
!             }
            }
          }
        }
Comment 1 Kay Abendroth 2006-11-12 11:04:39 UTC
Do you have this problem in 1.2.14 also?
Comment 2 Curt Arnold 2007-02-21 15:40:31 UTC
Bug is in 1.2.14, SyslogAppenderTest.testBadTabbing will throw an exception without code fix.

Committed against 1.2 branch in rev 510307.

Corresponding code in trunk has been commented out earlier.