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. *
|
|
|
|
|
* *
|
|
|
|
|
***************************************************************************/
|
2008-01-18 16:08:04 +00:00
|
|
|
package utilities;
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.List;
|
2017-05-28 01:03:01 +02:00
|
|
|
|
2008-01-18 16:08:04 +00: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
|
|
|
|
2009-02-25 23:42:55 +00:00
|
|
|
public static final Log4JAppender INSTANCE = new Log4JAppender();
|
2017-05-28 01:03:01 +02:00
|
|
|
|
2009-02-26 21:19:36 +00:00
|
|
|
private static List<String> messages = new ArrayList<String>();
|
2017-05-28 01:03:01 +02:00
|
|
|
|
2008-01-18 16:08:04 +00:00
|
|
|
|
|
|
|
|
@Override
|
2008-07-12 14:44:47 +00:00
|
|
|
protected void append(final LoggingEvent event) {
|
2008-01-18 16:08:04 +00:00
|
|
|
messages.add(event.getRenderedMessage());
|
|
|
|
|
}
|
|
|
|
|
|
2013-04-25 21:50:35 +00:00
|
|
|
@Override
|
2008-01-18 16:08:04 +00:00
|
|
|
public void close() {
|
2010-09-19 01:29:21 +00:00
|
|
|
// do nothing
|
2008-01-18 16:08:04 +00:00
|
|
|
}
|
|
|
|
|
|
2013-04-25 21:50:35 +00:00
|
|
|
@Override
|
2008-01-18 16:08:04 +00:00
|
|
|
public boolean requiresLayout() {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static String[] getMessages() {
|
2008-01-20 19:16:58 +00:00
|
|
|
return messages.toArray(new String[messages.size()]);
|
2008-01-18 16:08:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void clear() {
|
|
|
|
|
messages.clear();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|