com.sodius.mdw.core.util.log
Class SystemStream

java.lang.Object
  extended by com.sodius.mdw.core.util.log.SystemStream

public final class SystemStream
extends Object

Provides methods to redirect System.out and System.err streams to a logger.

For example, you can redirect System stream messages into a file using the following code :

FileLogger fileLogger = new FileLogger(new File("myFile.log"));
SystemStream.connect(fileLogger);
workbench.getConfiguration().setLogger(fileLogger);

This class cannot be instantiated or subclassed by clients.


Method Summary
static void connect(Logger logger)
          Redirects System.out and System.err streams to the specified logger.
static void disconnect()
          Restores the original streams to System.out and System.err.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

connect

public static void connect(Logger logger)
Redirects System.out and System.err streams to the specified logger.

When a logger is connected to system streams, any call to System.out.print() will be redirected to the logger info() method, and any call to System.err.print() will be redirected to the logger error() method. Additionally, the messages will still be written into the original System.out and System.err streams

.

Parameters:
logger - the logger which should receive any information written in System.out and System.err streams.

disconnect

public static void disconnect()
Restores the original streams to System.out and System.err.