Package gov.usgs.util.logging
Class LoggingOutputStream
java.lang.Object
java.io.OutputStream
java.io.ByteArrayOutputStream
gov.usgs.util.logging.LoggingOutputStream
- All Implemented Interfaces:
Closeable
,Flushable
,AutoCloseable
An OutputStream that writes contents to a Logger upon each call to flush().
From http://blogs.sun.com/nickstephen/entry/java_redirecting_system_out_and
-
Field Summary
Fields inherited from class java.io.ByteArrayOutputStream
buf, count
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
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, toString, write, write, writeBytes, writeTo
Methods inherited from class java.io.OutputStream
nullOutputStream, write
-
Constructor Details
-
LoggingOutputStream
Constructor- Parameters:
logger
- Logger to write tolevel
- Level at which to write the log message
-
-
Method Details
-
flush
upon flush() write the existing contents of the OutputStream to the logger as a log record.- Specified by:
flush
in interfaceFlushable
- Overrides:
flush
in classOutputStream
- Throws:
IOException
- in case of error
-