public final class SystemStream extends Object
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.
Modifier and Type | Method and Description |
---|---|
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 . |
public static void connect(Logger logger)
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
logger
- the logger which should receive any information written in System.out
and System.err
streams.public static void disconnect()
System.out
and System.err
.