Skip to content

Instantly share code, notes, and snippets.

View mike-duvall's full-sized avatar

Mike DuVall mike-duvall

View GitHub Profile
@mike-duvall
mike-duvall / LogLevelTripwireAppender
Last active December 21, 2015 01:49
For a specific JUnit integration test I was coding, I wanted the test to fail if an errors were logged to logback. I created this appender to record if errors were logged. Once the test is finished, the JUnit test asks the appender if errors were logged and fails the test if so.
import java.io.IOException;
import ch.qos.logback.classic.Level;
import ch.qos.logback.classic.encoder.PatternLayoutEncoder;
import ch.qos.logback.classic.spi.ILoggingEvent;
import ch.qos.logback.core.AppenderBase;
public class LogLevelTripwireAppender extends AppenderBase<ILoggingEvent> {