Package org.apache.log.util
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 booleanprivate final Loggerprivate final StringBufferprivate final Priority -
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 java.io.OutputStream
nullOutputStream, write, write
-
Field Details
-
m_logger
-
m_priority
-
m_output
-
m_closed
private boolean m_closed
-
-
Constructor Details
-
LoggerOutputStream
Construct OutputStreamLogger to write to a particular logger at a particular priority.- Parameters:
logger- the logger to write topriority- the priority at which to log
-
-
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
-