dk.netarkivet.common.utils
Class LoggingOutputStream

java.lang.Object
  extended by java.io.OutputStream
      extended by 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: ")));


Nested Class Summary
static class LoggingOutputStream.LoggingLevel
          Enum representing the standard logging levels for commons logging.
 
Constructor Summary
LoggingOutputStream(LoggingOutputStream.LoggingLevel loggingLevel, org.apache.commons.logging.Log logger, java.lang.String prefix)
          Constructor for the class.
 
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
 

Constructor Detail

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.
Method Detail

write

public void write(int b)
           throws java.io.IOException
Specified by:
write in class java.io.OutputStream
Throws:
java.io.IOException