1 package ch.qos.logback.core.testUtil; 2 3 import java.util.ArrayList; 4 import java.util.List; 5 6 import ch.qos.logback.core.AppenderBase; 7 import ch.qos.logback.core.Layout; 8 9 public class StringListAppender<E> extends AppenderBase<E> { 10 11 Layout<E> layout; 12 public List<String> strList = new ArrayList<String>(); 13 14 public StringListAppender() { 15 16 } 17 18 public void start() { 19 strList.clear(); 20 21 if (layout == null || !layout.isStarted()) { 22 return; 23 } 24 super.start(); 25 } 26 27 public void stop() { 28 super.stop(); 29 } 30 31 @Override 32 protected void append(E eventObject) { 33 String res = layout.doLayout(eventObject); 34 strList.add(res); 35 } 36 37 @Override 38 public Layout<E> getLayout() { 39 return layout; 40 } 41 42 @Override 43 public void setLayout(Layout<E> layout) { 44 this.layout = layout; 45 } 46 }