Class LoggerOutputStream
java.lang.Object
java.io.OutputStream
org.apache.log.util.LoggerOutputStream
- All Implemented Interfaces:
Closeable, Flushable, AutoCloseable
Redirect an output stream to a logger.
This class is useful to redirect standard output or
standard error to a Logger. An example use is
final LoggerOutputStream outputStream =
new LoggerOutputStream( logger, Priority.DEBUG );
final PrintStream output = new PrintStream( outputStream, true );
System.setOut( output );
- Author:
- Avalon Development Team, Peter Donald
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate booleanFlag set to true once stream closedprivate final LoggerLogger that we log toprivate final StringBufferThe buffered output so farprivate final PriorityLog level we log to -
Constructor Summary
ConstructorsConstructorDescriptionLoggerOutputStream(Logger logger, Priority priority) Construct OutputStreamLogger to write to a particular logger at a particular priority. -
Method Summary
Methods inherited from class OutputStream
nullOutputStream, write, write
-
Field Details
-
m_logger
Logger that we log to -
m_priority
Log level we log to -
m_output
The buffered output so far -
m_closed
private boolean m_closedFlag set to true once stream closed
-
-
Constructor Details
-
LoggerOutputStream
-
-
Method Details
-
close
Shutdown stream.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classOutputStream- Throws:
IOException- if an error occurs while closing the stream
-
write
Write a single byte of data to output stream.- Specified by:
writein classOutputStream- Parameters:
data- the byte of data- Throws:
IOException- if an error occurs
-
flush
Flush data to underlying logger.- Specified by:
flushin interfaceFlushable- Overrides:
flushin classOutputStream- Throws:
IOException- if an error occurs
-
checkValid
Make sure stream is valid.- Throws:
IOException- if an error occurs
-