Package org.apache.log.util
Class LoggerOutputStream
- java.lang.Object
-
- java.io.OutputStream
-
- org.apache.log.util.LoggerOutputStream
-
- All Implemented Interfaces:
java.io.Closeable,java.io.Flushable,java.lang.AutoCloseable
public class LoggerOutputStream extends java.io.OutputStreamRedirect an output stream to a logger. This class is useful to redirect standard output or standard error to a Logger. An example use isfinal LoggerOutputStream outputStream = new LoggerOutputStream( logger, Priority.DEBUG ); final PrintStream output = new PrintStream( outputStream, true ); System.setOut( output );- Author:
- Avalon Development Team, Peter Donald
-
-
Constructor Summary
Constructors Constructor Description LoggerOutputStream(Logger logger, Priority priority)Construct OutputStreamLogger to write to a particular logger at a particular priority.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidcheckValid()Make sure stream is valid.voidclose()Shutdown stream.voidflush()Flush data to underlying logger.voidwrite(int data)Write a single byte of data to output stream.
-
-
-
Method Detail
-
close
public void close() throws java.io.IOExceptionShutdown stream.- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Overrides:
closein classjava.io.OutputStream- Throws:
java.io.IOException- if an error occurs while closing the stream
-
write
public void write(int data) throws java.io.IOExceptionWrite a single byte of data to output stream.- Specified by:
writein classjava.io.OutputStream- Parameters:
data- the byte of data- Throws:
java.io.IOException- if an error occurs
-
flush
public void flush() throws java.io.IOExceptionFlush data to underlying logger.- Specified by:
flushin interfacejava.io.Flushable- Overrides:
flushin classjava.io.OutputStream- Throws:
java.io.IOException- if an error occurs
-
checkValid
private void checkValid() throws java.io.IOExceptionMake sure stream is valid.- Throws:
java.io.IOException- if an error occurs
-
-