You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@chukwa.apache.org by as...@apache.org on 2009/03/30 06:30:23 UTC

svn commit: r759837 - in /hadoop/chukwa/trunk: CHANGES.txt src/java/org/apache/hadoop/chukwa/inputtools/log4j/ChukwaDailyRollingFileAppender.java

Author: asrabkin
Date: Mon Mar 30 04:30:23 2009
New Revision: 759837

URL: http://svn.apache.org/viewvc?rev=759837&view=rev
Log:
CHUKWA-41.  ChukwaLog4jAppender does not escape \n for exception.  Contributed by Jerome Boulon.

Modified:
    hadoop/chukwa/trunk/CHANGES.txt
    hadoop/chukwa/trunk/src/java/org/apache/hadoop/chukwa/inputtools/log4j/ChukwaDailyRollingFileAppender.java

Modified: hadoop/chukwa/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/chukwa/trunk/CHANGES.txt?rev=759837&r1=759836&r2=759837&view=diff
==============================================================================
--- hadoop/chukwa/trunk/CHANGES.txt (original)
+++ hadoop/chukwa/trunk/CHANGES.txt Mon Mar 30 04:30:23 2009
@@ -35,6 +35,8 @@
 
   BUG FIXES
 
+    CHUKWA-41.  ChukwaLog4jAppender does not escape \n for exception.  (Jerome Boulon via asrabkin)
+
     CHUKWA-28.  Late initalization of log4j adaptor.  (Jerome Boulon via asrabkin)
 
     CHUKWA-48.  Cleanup code to resolve compiler warnings.  (asrabkin)

Modified: hadoop/chukwa/trunk/src/java/org/apache/hadoop/chukwa/inputtools/log4j/ChukwaDailyRollingFileAppender.java
URL: http://svn.apache.org/viewvc/hadoop/chukwa/trunk/src/java/org/apache/hadoop/chukwa/inputtools/log4j/ChukwaDailyRollingFileAppender.java?rev=759837&r1=759836&r2=759837&view=diff
==============================================================================
--- hadoop/chukwa/trunk/src/java/org/apache/hadoop/chukwa/inputtools/log4j/ChukwaDailyRollingFileAppender.java (original)
+++ hadoop/chukwa/trunk/src/java/org/apache/hadoop/chukwa/inputtools/log4j/ChukwaDailyRollingFileAppender.java Mon Mar 30 04:30:23 2009
@@ -588,22 +588,28 @@
           LogLog.error("rollOver() failed.", ioe);
         }
       }
-      // escape the newlines from record bodies and then write this record to
-      // the log file
-      this.qw.write(RecordConstants.escapeAllButLastRecordSeparator("\n",
-          this.layout.format(event)));
 
-      if (layout.ignoresThrowable()) {
+      boolean written = false;
+      if(layout.ignoresThrowable()) {
         String[] s = event.getThrowableStrRep();
         if (s != null) {
           int len = s.length;
-          for (int i = 0; i < len; i++) {
-            this.qw.write(s[i]);
-            this.qw.write(Layout.LINE_SEP);
+          StringBuilder sb = new StringBuilder();
+          sb.append(this.layout.format(event));
+          for(int i = 0; i < len; i++) {
+            sb.append(s[i]).append("\n");
           }
-        }
+          //escape the newlines from record bodies, exception and then write this record to the log file
+          written = true;
+          this.qw.write(RecordConstants.escapeAllButLastRecordSeparator("\n",sb.toString()));
+        } 
       }
-
+       
+      if (!written) {
+        //escape the newlines from record bodies and then write this record to the log file
+        this.qw.write(RecordConstants.escapeAllButLastRecordSeparator("\n",this.layout.format(event)));
+      }
+      
       if (this.immediateFlush) {
         this.qw.flush();
       }