textArea.setRows(10);
textArea.setFont(new Font(Font.MONOSPACED, Font.PLAIN, 12));
textArea.setEditable(false);
WriterAppender appender = new WriterAppender() {
public void append(LoggingEvent loggingEvent) {
final String message = this.getLayout().format(loggingEvent);
SwingUtilities.invokeLater(new Runnable() {
public void run() {
textArea.append(message);
textArea.setCaretPosition(textArea.getDocument().getLength());
}
});
}
};
appender.setLayout(layout);
Logger.getRootLogger().removeAllAppenders();
Logger.getRootLogger().addAppender(appender);
this.setLayout(new BorderLayout());