1   /**
2    * Logback: the generic, reliable, fast and flexible logging framework.
3    * 
4    * Copyright (C) 2000-2008, QOS.ch
5    * 
6    * This library is free software, you can redistribute it and/or modify it under
7    * the terms of the GNU Lesser General Public License as published by the Free
8    * Software Foundation.
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  }