MATSIM
CollectLogMessagesAppender.java
Go to the documentation of this file.
1 /* *********************************************************************** *
2  * project: org.matsim.*
3  * CollectLogMessagesAppender
4  * *
5  * *********************************************************************** *
6  * *
7  * copyright : (C) 2008 by the members listed in the COPYING, *
8  * LICENSE and WARRANTY file. *
9  * email : info at matsim dot org *
10  * *
11  * *********************************************************************** *
12  * *
13  * This program is free software; you can redistribute it and/or modify *
14  * it under the terms of the GNU General Public License as published by *
15  * the Free Software Foundation; either version 2 of the License, or *
16  * (at your option) any later version. *
17  * See also COPYING, LICENSE and WARRANTY file *
18  * *
19  * *********************************************************************** */
20 package org.matsim.core.utils.io;
21 
22 import org.apache.logging.log4j.Level;
23 import org.apache.logging.log4j.core.LogEvent;
24 import org.apache.logging.log4j.core.appender.AbstractAppender;
25 import org.apache.logging.log4j.core.config.Property;
26 import org.apache.logging.log4j.core.filter.ThresholdFilter;
28 
29 import java.util.concurrent.ConcurrentLinkedQueue;
30 import java.util.Queue;
31 
32 
38 public class CollectLogMessagesAppender extends AbstractAppender {
39 
40  private Queue<LogEvent> logEvents = new ConcurrentLinkedQueue<>();
41 
43  super("collector",
44  ThresholdFilter.createFilter(Level.ALL, null, null),
46  false,
47  new Property[0]);
48  }
49 
50  @Override
51  public void append(LogEvent e) {
52  this.logEvents.add(e.toImmutable());
53  }
54 
55  public Queue<LogEvent> getLogEvents() {
56  return this.logEvents;
57  }
58 
59 }
static final PatternLayout DEFAULTLOG4JLAYOUT
Definition: Controler.java:114