info.aduna.autofocus.util
Class LoggingOutputStream
java.lang.Object
java.io.OutputStream
java.io.ByteArrayOutputStream
info.aduna.autofocus.util.LoggingOutputStream
- All Implemented Interfaces:
- Closeable, Flushable
public class LoggingOutputStream
- extends ByteArrayOutputStream
An OutputStream that writes contents to a Logger upon each call to flush().
This code was derived from code found at
http://blogs.sun.com/nickstephen/entry/java_redirecting_system_out_and,
changing the use of java.util.logging with SLF4J.
Warning: when using this class to redirect System.out and System.err to a
Logger, take extreme care that the Logger specified to the constructor does
not print to System.out or System.err (as e.g. the SimpleLogger does), or you
will run into an infinite loop.
|
Method Summary |
void |
flush()
Writes the existing contents of the OutputStream to the Logger. |
LoggingOutputStream
public LoggingOutputStream(org.slf4j.Logger logger,
boolean warn)
flush
public void flush()
throws IOException
- Writes the existing contents of the OutputStream to the Logger.
- Specified by:
flush in interface Flushable- Overrides:
flush in class OutputStream
- Throws:
IOException
Copyright © 1997-2008 Aduna. All Rights Reserved.