package com.lambdaworks;

import java.io.PrintWriter;
import java.io.StringWriter;

import org.apache.log4j.WriterAppender;
import org.apache.log4j.spi.LoggingEvent;

/**
 * @author <a href="mailto:mpaluch@paluch.biz">Mark Paluch</a>
 */
public class CapturingLogAppender extends WriterAppender {

    private static StringWriter writer = new StringWriter();

    public CapturingLogAppender() {
        super();
        setWriter(new PrintWriter(writer));
    }

    public static String getContentAndReset() {
        String result = writer.getBuffer().toString();
        writer.getBuffer().setLength(0);

        return result;
    }

    @Override
    public synchronized void doAppend(LoggingEvent event) {
        super.doAppend(event);
    }
}

@@ -351,16 +351,59 @@
 riter();
+%0A    private static boolean enabled = true;
 %0A%0A    pu
@@ -761,29 +761,198 @@
     
-super.doAppend(event)
+if (enabled) %7B%0A            super.doAppend(event);%0A        %7D%0A    %7D%0A%0A    public static void disable() %7B%0A        enabled = false;%0A    %7D%0A%0A    public static void enable() %7B%0A        enabled = true
 ;%0A  

Allow to disable log capturing during tests #84