1
2
3
4
5
6
7
8
9
10
11
12
13
14 package ch.qos.logback.classic;
15
16 import java.util.ArrayList;
17 import java.util.List;
18
19 import org.slf4j.Logger;
20 import org.slf4j.LoggerFactory;
21
22 import ch.qos.logback.classic.spi.ILoggingEvent;
23 import ch.qos.logback.core.AppenderBase;
24 import ch.qos.logback.core.testUtil.RandomUtil;
25
26 public class RecursiveLBAppender extends AppenderBase<ILoggingEvent> {
27
28 public List<ILoggingEvent> list = new ArrayList<ILoggingEvent>();
29 public List<String> stringList = new ArrayList<String>();
30
31 PatternLayout layout;
32
33 public RecursiveLBAppender() {
34 this(null);
35 }
36
37 public RecursiveLBAppender(PatternLayout layout) {
38 this.layout = layout;
39 }
40
41 @Override
42 public void start() {
43 int diff = RandomUtil.getPositiveInt();
44 Logger logger = LoggerFactory.getLogger("ResursiveLBAppender" + diff);
45 logger.info("testing");
46 super.start();
47 }
48
49 protected void append(ILoggingEvent e) {
50 list.add(e);
51 if (layout != null) {
52 String s = layout.doLayout(e);
53 stringList.add(s);
54 }
55 }
56 }