Class AbstractOutputTarget
java.lang.Object
org.apache.log.output.AbstractTarget
org.apache.log.output.AbstractOutputTarget
- All Implemented Interfaces:
ErrorAware, LogTarget, Closeable
- Direct Known Subclasses:
DatagramOutputTarget, NullOutputLogTarget, ServletOutputLogTarget, SMTPOutputLogTarget, SocketOutputTarget, StreamTarget, WriterTarget
Abstract output target.
Any new output target that is writing to a single connected
resource should extend this class directly or indirectly.
- Author:
- Avalon Development Team, Peter Donald
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionParameterless constructor.AbstractOutputTarget(Formatter formatter) Creation of a new abstract output target instance. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Shutdown target.protected voiddoProcessEvent(LogEvent event) Process a log event.private StringHelper method to format an event into a string, using the formatter if available.protected FormatterReturns the Formatter.private StringgetHead()Helper method to retrieve head for log session.private StringgetTail()Helper method to retrieve tail for log session.protected voidopen()Startup log session.protected voidAbstract method to write data.private voidHelper method to write out log head.private voidHelper method to write out log tail.Methods inherited from class AbstractTarget
getErrorHandler, isOpen, processEvent, setErrorHandler
-
Field Details
-
m_formatter
Formatter for target.
-
-
Constructor Details
-
AbstractOutputTarget
public AbstractOutputTarget()Parameterless constructor. -
AbstractOutputTarget
Creation of a new abstract output target instance.- Parameters:
formatter- the formatter to apply
-
-
Method Details
-
getFormatter
Returns the Formatter. -
write
Abstract method to write data.- Parameters:
data- the data to be output
-
doProcessEvent
Process a log event.- Specified by:
doProcessEventin classAbstractTarget- Parameters:
event- the event to process
-
open
-
close
public void close()Shutdown target. Attempting to write to target after close() will cause errors to be logged.- Specified by:
closein interfaceCloseable- Overrides:
closein classAbstractTarget
-
format
-
writeHead
private void writeHead()Helper method to write out log head. The head initiates a session of logging. -
writeTail
private void writeTail()Helper method to write out log tail. The tail completes a session of logging. -
getHead
Helper method to retrieve head for log session. TODO: Extract from formatter- Returns:
- the head string
-
getTail
Helper method to retrieve tail for log session. TODO: Extract from formatter- Returns:
- the head string
-