You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@continuum.apache.org by ba...@apache.org on 2015/04/29 16:43:34 UTC

svn commit: r1676759 - /continuum/trunk/continuum-webapp/src/main/java/org/apache/continuum/web/util/FixedBufferAppender.java

Author: batkinson
Date: Wed Apr 29 14:43:34 2015
New Revision: 1676759

URL: http://svn.apache.org/r1676759
Log:
Buffer log appender now properly logs stack traces.

Modified:
    continuum/trunk/continuum-webapp/src/main/java/org/apache/continuum/web/util/FixedBufferAppender.java

Modified: continuum/trunk/continuum-webapp/src/main/java/org/apache/continuum/web/util/FixedBufferAppender.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-webapp/src/main/java/org/apache/continuum/web/util/FixedBufferAppender.java?rev=1676759&r1=1676758&r2=1676759&view=diff
==============================================================================
--- continuum/trunk/continuum-webapp/src/main/java/org/apache/continuum/web/util/FixedBufferAppender.java (original)
+++ continuum/trunk/continuum-webapp/src/main/java/org/apache/continuum/web/util/FixedBufferAppender.java Wed Apr 29 14:43:34 2015
@@ -2,6 +2,7 @@ package org.apache.continuum.web.util;
 
 import org.apache.log4j.AppenderSkeleton;
 import org.apache.log4j.spi.LoggingEvent;
+import org.apache.log4j.spi.ThrowableInformation;
 
 import java.util.Collection;
 import java.util.Collections;
@@ -22,8 +23,23 @@ public class FixedBufferAppender
     protected void append( LoggingEvent event )
     {
         String formattedLine = layout.format( event );
+
+        // Add formatted line (may contain throwable if layout handles)
         lines.add( formattedLine );
         queued++;
+
+        // Add throwable information if layout doesn't handle
+        ThrowableInformation throwInfo = event.getThrowableInformation();
+        if ( throwInfo != null && layout.ignoresThrowable() )
+        {
+            for ( String traceLine : throwInfo.getThrowableStrRep() )
+            {
+                lines.add( String.format( "%s%n", traceLine ) );
+                queued++;
+            }
+        }
+
+        // Shrink the queue back to the desired buffer size (temporarily gets larger)
         while ( queued > linesBuffered )
         {
             lines.remove();