stendhal/tests/utilities/Log4JAppender.java

52 lines
1.6 KiB
Java
Raw Permalink Normal View History

2010-09-19 01:29:21 +00:00
/* $Id$ */
/***************************************************************************
* (C) Copyright 2003-2010 - Stendhal *
***************************************************************************
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
package utilities;
import java.util.ArrayList;
import java.util.List;
2017-05-28 01:03:01 +02:00
import org.apache.log4j.AppenderSkeleton;
import org.apache.log4j.spi.LoggingEvent;
public class Log4JAppender extends AppenderSkeleton {
2017-05-28 01:03:01 +02:00
public static final Log4JAppender INSTANCE = new Log4JAppender();
2017-05-28 01:03:01 +02:00
private static List<String> messages = new ArrayList<String>();
2017-05-28 01:03:01 +02:00
@Override
protected void append(final LoggingEvent event) {
messages.add(event.getRenderedMessage());
}
2013-04-25 21:50:35 +00:00
@Override
public void close() {
2010-09-19 01:29:21 +00:00
// do nothing
}
2013-04-25 21:50:35 +00:00
@Override
public boolean requiresLayout() {
return false;
}
public static String[] getMessages() {
return messages.toArray(new String[messages.size()]);
}
public static void clear() {
messages.clear();
}
}