1
2
3
4
5
6
7
8
9
10 package org.dummy;
11
12 import java.util.ArrayList;
13 import java.util.List;
14
15 import ch.qos.logback.classic.PatternLayout;
16 import ch.qos.logback.classic.spi.LoggingEvent;
17 import ch.qos.logback.core.AppenderBase;
18
19 public class DummyLBAppender extends AppenderBase<LoggingEvent> {
20
21 public List<LoggingEvent> list = new ArrayList<LoggingEvent>();
22 public List<String> stringList = new ArrayList<String>();
23
24 PatternLayout layout;
25
26 DummyLBAppender() {
27 this(null);
28 }
29
30 DummyLBAppender(PatternLayout layout) {
31 this.layout = layout;
32 }
33
34 protected void append(LoggingEvent e) {
35 list.add(e);
36 if(layout != null) {
37 String s = layout.doLayout(e);
38 stringList.add(s);
39 }
40 }
41 }