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

public abstract Class AbstractOutputTarget

extends AbstractTarget
Class Inheritance
Known Direct Subclasses
org.apache.log.output.NullOutputLogTarget, org.apache.log.output.ServletOutputLogTarget, org.apache.log.output.io.StreamTarget, org.apache.log.output.io.WriterTarget, org.apache.log.output.net.DatagramOutputTarget, org.apache.log.output.net.SMTPOutputLogTarget, org.apache.log.output.net.SocketOutputTarget
Imports
org.apache.log.LogEvent, org.apache.log.format.Formatter

Abstract output target. Any new output target that is writing to a single connected resource should extend this class directly or indirectly.
Authors
Avalon Development Team, Peter Donald

Field Summary

Modifier and TypeField and Description
private Formatter
m_formatter

Formatter for target.

Constructor Summary

AccessConstructor and Description
public
AbstractOutputTarget()

Parameterless constructor.

public
AbstractOutputTarget(final Formatter
the formatter to apply
formatter
)

Creation of a new abstract output target instance.

Method Summary

Modifier and TypeMethod and Description
public synchronized void
protected void
doProcessEvent(LogEvent
the event to process
event
)

Implements abstract org.apache.log.output.AbstractTarget.doProcessEvent.

Process a log event.
private String

Returns:

the formatted string
format
(final LogEvent
the LogEvent
event
)

Helper method to format an event into a string, using the formatter if available.

protected Formatter
getFormatter()

Returns the Formatter.

private String

Returns:

the head string
getHead
()

Helper method to retrieve head for log session.

private String

Returns:

the head string
getTail
()

Helper method to retrieve tail for log session.

protected synchronized void
open()

Overrides org.apache.log.output.AbstractTarget.open.

Startup log session.
protected void
write(final String
the data to be output
data
)

Abstract method to write data.

private void
writeHead()

Helper method to write out log head.

private void
writeTail()

Helper method to write out log tail.

Inherited from org.apache.log.output.AbstractTarget:
getErrorHandlerisOpenprocessEventsetErrorHandler

Field Detail

m_formatterback to summary
private Formatter m_formatter

Formatter for target.

Constructor Detail

AbstractOutputTargetback to summary
public AbstractOutputTarget()

Parameterless constructor.

AbstractOutputTargetback to summary
public AbstractOutputTarget(final Formatter formatter)

Creation of a new abstract output target instance.

Parameters
formatter:Formatter

the formatter to apply

Method Detail

closeback to summary
public synchronized void close()

Overrides org.apache.log.output.AbstractTarget.close.

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

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

doProcessEventback to summary
protected void doProcessEvent(LogEvent event)

Implements abstract org.apache.log.output.AbstractTarget.doProcessEvent.

Process a log event.

Parameters
event:LogEvent

the event to process

formatback to summary
private String format(final LogEvent event)

Helper method to format an event into a string, using the formatter if available.

Parameters
event:LogEvent

the LogEvent

Returns:String

the formatted string

getFormatterback to summary
protected Formatter getFormatter()

Returns the Formatter.

getHeadback to summary
private String getHead()

Helper method to retrieve head for log session. TODO: Extract from formatter

Returns:String

the head string

getTailback to summary
private String getTail()

Helper method to retrieve tail for log session. TODO: Extract from formatter

Returns:String

the head string

openback to summary
protected synchronized void open()

Overrides org.apache.log.output.AbstractTarget.open.

Startup log session.

writeback to summary
protected void write(final String data)

Abstract method to write data.

Parameters
data:String

the data to be output

writeHeadback to summary
private void writeHead()

Helper method to write out log head. The head initiates a session of logging.

writeTailback to summary
private void writeTail()

Helper method to write out log tail. The tail completes a session of logging.