com.metsci.glimpse.util.logging
Class LoggerUtils.LoggingOutputStream

java.lang.Object
  extended by java.io.OutputStream
      extended by java.io.ByteArrayOutputStream
          extended by com.metsci.glimpse.util.logging.LoggerUtils.LoggingOutputStream
All Implemented Interfaces:
java.io.Closeable, java.io.Flushable
Enclosing class:
LoggerUtils

public static class LoggerUtils.LoggingOutputStream
extends java.io.ByteArrayOutputStream

An OutputStream that writes contents to a Logger upon each call to flush() Original URL: https://blogs.oracle.com/nickstephen/entry/java_redirecting_system_out_and Author gives permission for free use in blog comments section.


Constructor Summary
LoggerUtils.LoggingOutputStream(java.util.logging.Logger logger, java.util.logging.Level level)
          Constructor
 
Method Summary
 void flush()
          upon flush() write the existing contents of the OutputStream to the logger as a log record.
 
Methods inherited from class java.io.ByteArrayOutputStream
close, reset, size, toByteArray, toString, toString, toString, write, write, writeTo
 
Methods inherited from class java.io.OutputStream
write
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

LoggerUtils.LoggingOutputStream

public LoggerUtils.LoggingOutputStream(java.util.logging.Logger logger,
                                       java.util.logging.Level level)
Constructor

Parameters:
logger - Logger to write to
level - Level at which to write the log message
Method Detail

flush

public void flush()
           throws java.io.IOException
upon flush() write the existing contents of the OutputStream to the logger as a log record.

Specified by:
flush in interface java.io.Flushable
Overrides:
flush in class java.io.OutputStream
Throws:
java.io.IOException - in case of error


Copyright © 2012 Metron, Inc.. All Rights Reserved.