dk.netarkivet.common.utils
Class LoggingOutputStream
java.lang.Object
java.io.OutputStream
dk.netarkivet.common.utils.LoggingOutputStream
- All Implemented Interfaces:
- java.io.Closeable, java.io.Flushable
public class LoggingOutputStream
- extends java.io.OutputStream
OutputStream which can be used to redirect all stdout and stderr to a logger.
Usage:
System.setOut(new PrintStream(new LoggingOutputStream(LoggingOutputStream.LoggingLevel.INFO, log, "StdOut: ")));
System.setErr(new PrintStream(new LoggingOutputStream(LoggingOutputStream.LoggingLevel.WARN, log, "StdErr: ")));
Method Summary |
void |
write(int b)
|
Methods inherited from class java.io.OutputStream |
close, flush, write, write |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
LoggingOutputStream
public LoggingOutputStream(LoggingOutputStream.LoggingLevel loggingLevel,
org.apache.commons.logging.Log logger,
java.lang.String prefix)
- Constructor for the class.
- Parameters:
loggingLevel
- The logging level at which to log messages from this instance.logger
- The logger to which messages will be logged.prefix
- A prefix by which output from this instance can be identified.
write
public void write(int b)
throws java.io.IOException
- Specified by:
write
in class java.io.OutputStream
- Throws:
java.io.IOException