DubboAppender extends FileAppender { @Override public void append(LoggingEvent event) { super.append(event); if (available) { Log temp = parseLog(event); logList.add(temp); } } DubboAppender(); static void doStart(); static void doStop(); static void clear(); @Override void append(LoggingEvent event); static boolean available; static List<Log> logList; }
@Test public void testAppend() throws Exception { DubboAppender appender = new DubboAppender(); appender.append(event); assertThat(DubboAppender.logList, hasSize(0)); DubboAppender.doStart(); appender.append(event); assertThat(DubboAppender.logList, hasSize(1)); Log log = DubboAppender.logList.get(0); assertThat(log.getLogThread(), equalTo("thread-name")); }