Top Description Fields Constructors Methods
org.apache.log.util

public Class LoggerOutputStream

extends OutputStream
Class Inheritance
Imports
java.io.EOFException, .IOException, .OutputStream, org.apache.log.Logger, .Priority

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 );
Authors
Avalon Development Team, Peter Donald

Field Summary

Modifier and TypeField and Description
private boolean
private final Logger
private final StringBuffer
private final Priority

Constructor Summary

AccessConstructor and Description
public
LoggerOutputStream(final Logger
the logger to write to
logger
,
final Priority
the priority at which to log
priority
)

Construct OutputStreamLogger to write to a particular logger at a particular priority.

Method Summary

Modifier and TypeMethod and Description
private void
checkValid()

Make sure stream is valid.

public void
close()

Overrides java.io.OutputStream.close.

Implements java.io.Closeable.close.

Shutdown stream.
public synchronized void
flush()

Overrides java.io.OutputStream.flush.

Implements java.io.Flushable.flush.

Flush data to underlying logger.
public void
write(final int
the byte of data
data
)

Implements abstract java.io.OutputStream.write.

Write a single byte of data to output stream.
Inherited from java.io.OutputStream:
nullOutputStreamwritewrite

Field Detail

m_closedback to summary
private boolean m_closed
m_loggerback to summary
private final Logger m_logger
m_outputback to summary
private final StringBuffer m_output
m_priorityback to summary
private final Priority m_priority

Constructor Detail

LoggerOutputStreamback to summary
public LoggerOutputStream(final Logger logger, final Priority priority)

Construct OutputStreamLogger to write to a particular logger at a particular priority.

Parameters
logger:Logger

the logger to write to

priority:Priority

the priority at which to log

Method Detail

checkValidback to summary
private void checkValid() throws IOException

Make sure stream is valid.

Exceptions
IOException:
if an error occurs
closeback to summary
public void close() throws IOException

Overrides java.io.OutputStream.close.

Implements java.io.Closeable.close.

Shutdown stream.

Exceptions
IOException:
if an error occurs while closing the stream
flushback to summary
public synchronized void flush() throws IOException

Overrides java.io.OutputStream.flush.

Implements java.io.Flushable.flush.

Flush data to underlying logger.

Exceptions
IOException:
if an error occurs
writeback to summary
public void write(final int data) throws IOException

Implements abstract java.io.OutputStream.write.

Write a single byte of data to output stream.

Parameters
data:int

the byte of data

Exceptions
IOException:
if an error occurs