Here you can find the source of initLogConsole(final JTextArea textArea)
public static void initLogConsole(final JTextArea textArea)
//package com.java2s; //License from project: Apache License import java.io.FileNotFoundException; import java.io.IOException; import java.io.OutputStream; import java.io.PrintStream; import javax.swing.JTextArea; import org.springframework.util.Log4jConfigurer; import org.springframework.util.ResourceUtils; public class Main { public static void initLogConsole(String workingDirSystemProperty, String logFileClassPath, long refreshInteval) throws FileNotFoundException { Log4jConfigurer.setWorkingDirSystemProperty(workingDirSystemProperty); Log4jConfigurer.initLogging(ResourceUtils.CLASSPATH_URL_PREFIX + logFileClassPath, refreshInteval); }/*from w ww .j a v a 2s . co m*/ public static void initLogConsole(final JTextArea textArea) { OutputStream textAreaStream = new OutputStream() { public void write(int b) throws IOException { clearTextArea(textArea); textArea.append(String.valueOf((char) b)); } public void write(byte b[]) throws IOException { clearTextArea(textArea); textArea.append(new String(b)); } public void write(byte b[], int off, int len) throws IOException { clearTextArea(textArea); textArea.append(new String(b, off, len)); } }; PrintStream myOut = new PrintStream(textAreaStream); System.setOut(myOut); System.setErr(myOut); } private static void clearTextArea(JTextArea textArea) { if (textArea.getLineCount() > 200) { textArea.setText(""); } } }