org.apache.log.output.io

Class StreamTarget

public class StreamTarget extends AbstractOutputTarget

A basic target that writes to an OutputStream.

Author: Peter Donald

Field Summary
Stringm_encoding
The encoding to use when creating byte array for string, may be null.
OutputStreamm_outputStream
OutputStream we are writing to.
Constructor Summary
StreamTarget(OutputStream outputStream, Formatter formatter, String encoding)
Constructor that writes to a stream and uses a particular formatter.
StreamTarget(OutputStream outputStream, Formatter formatter)
Constructor that writes to a stream and uses a particular formatter.
Method Summary
voidclose()
Shutdown target.
protected voidsetOutputStream(OutputStream outputStream)
Set the output stream.
protected voidshutdownStream()
Shutdown output stream.
protected voidwrite(String data)
Abstract method that will output event.

Field Detail

m_encoding

private String m_encoding
The encoding to use when creating byte array for string, may be null.

m_outputStream

private OutputStream m_outputStream
OutputStream we are writing to.

Constructor Detail

StreamTarget

public StreamTarget(OutputStream outputStream, Formatter formatter, String encoding)
Constructor that writes to a stream and uses a particular formatter.

Parameters: outputStream the OutputStream to write to formatter the Formatter to use encoding Desired encoding to use when writing to the log, null implies the default system encoding.

StreamTarget

public StreamTarget(OutputStream outputStream, Formatter formatter)
Constructor that writes to a stream and uses a particular formatter.

Parameters: outputStream the OutputStream to write to formatter the Formatter to use

Method Detail

close

public void close()
Shutdown target. Attempting to write to target after close() will cause errors to be logged.

setOutputStream

protected void setOutputStream(OutputStream outputStream)
Set the output stream. Close down old stream and write tail if appropriate.

Parameters: outputStream the new OutputStream

shutdownStream

protected void shutdownStream()
Shutdown output stream.

write

protected void write(String data)
Abstract method that will output event.

Parameters: data the data to be output