org.apache.log.output.io

Class StreamTarget

Implemented Interfaces:
ErrorAware, LogTarget
Known Direct Subclasses:
FileTarget

public class StreamTarget
extends AbstractOutputTarget

A basic target that writes to an OutputStream.
Author:
Peter Donald

Field Summary

Fields inherited from class org.apache.log.output.AbstractOutputTarget

m_formatter

Constructor Summary

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

Method Summary

void
close()
Shutdown target.
protected void
setOutputStream(OutputStream outputStream)
Set the output stream.
protected void
shutdownStream()
Shutdown output stream.
protected void
write(String data)
Abstract method that will output event.

Methods inherited from class org.apache.log.output.AbstractOutputTarget

close, doProcessEvent, getFormatter, open, output, setFormatter, write

Methods inherited from class org.apache.log.output.AbstractTarget

close, doProcessEvent, error, getErrorHandler, isOpen, open, processEvent, setErrorHandler

Constructor Details

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 Details

close

public void close()
Shutdown target. Attempting to write to target after close() will cause errors to be logged.
Overrides:
close in interface AbstractOutputTarget

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.
Overrides:
write in interface AbstractOutputTarget
Parameters:
data - the data to be output