Top Description Fields Constructors Methods
org.apache.log.output.io

public Class StreamTarget

extends AbstractOutputTarget
Class Inheritance
Known Direct Subclasses
org.apache.log.output.io.FileTarget
Imports
java.io.IOException, .OutputStream, org.apache.log.format.Formatter, org.apache.log.output.AbstractOutputTarget

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

Field Summary

Modifier and TypeField and Description
private String
m_encoding

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

private OutputStream
m_outputStream

OutputStream we are writing to.

Constructor Summary

AccessConstructor and Description
public
StreamTarget(final OutputStream
the OutputStream to write to
outputStream
,
final Formatter
the Formatter to use
formatter
,
final String
Desired encoding to use when writing to the log, null implies the default system encoding.
encoding
)

Constructor that writes to a stream and uses a particular formatter.

public
StreamTarget(final OutputStream
the OutputStream to write to
outputStream
,
final Formatter
the Formatter to use
formatter
)

Constructor that writes to a stream and uses a particular formatter.

Method Summary

Modifier and TypeMethod and Description
public synchronized void
protected synchronized void
setOutputStream(final OutputStream
the new OutputStream
outputStream
)

Set the output stream.

protected synchronized void
shutdownStream()

Shutdown output stream.

protected synchronized void
write(final String
the data to be output
data
)

Overrides org.apache.log.output.AbstractOutputTarget.write.

Abstract method that will output event.
Inherited from org.apache.log.output.AbstractOutputTarget:
doProcessEventgetFormatteropen

Field Detail

m_encodingback to summary
private String m_encoding

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

m_outputStreamback to summary
private OutputStream m_outputStream

OutputStream we are writing to.

Constructor Detail

StreamTargetback to summary
public StreamTarget(final OutputStream outputStream, final Formatter formatter, final String encoding)

Constructor that writes to a stream and uses a particular formatter.

Parameters
outputStream:OutputStream

the OutputStream to write to

formatter:Formatter

the Formatter to use

encoding:String

Desired encoding to use when writing to the log, null implies the default system encoding.

StreamTargetback to summary
public StreamTarget(final OutputStream outputStream, final Formatter formatter)

Constructor that writes to a stream and uses a particular formatter.

Parameters
outputStream:OutputStream

the OutputStream to write to

formatter:Formatter

the Formatter to use

Method Detail

closeback to summary
public synchronized void close()

Overrides org.apache.log.output.AbstractOutputTarget.close.

Implements org.apache.log.util.Closeable.close.

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

setOutputStreamback to summary
protected synchronized void setOutputStream(final OutputStream outputStream)

Set the output stream. Close down old stream and write tail if appropriate.

Parameters
outputStream:OutputStream

the new OutputStream

shutdownStreamback to summary
protected synchronized void shutdownStream()

Shutdown output stream.

writeback to summary
protected synchronized void write(final String data)

Overrides org.apache.log.output.AbstractOutputTarget.write.

Abstract method that will output event.

Parameters
data:String

the data to be output