org.apache.log.output.io

Class SafeFileTarget

Implemented Interfaces:
ErrorAware, LogTarget

public class SafeFileTarget
extends FileTarget

A target that will open and close a file for each logevent. This is slow but a more reliable form of logging on some filesystems/OSes. It should only be used when there is a small number of log events.
Author:
Peter Donald

Field Summary

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

m_formatter

Constructor Summary

SafeFileTarget(File file, boolean append, Formatter formatter)
Construct file target to write to a file with a formatter.

Method Summary

void
processEvent(LogEvent event)
Process a log event, via formatting and outputting it.

Methods inherited from class org.apache.log.output.io.FileTarget

getFile, openFile, setFile

Methods inherited from class org.apache.log.output.io.StreamTarget

close, setOutputStream, shutdownStream, write

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

SafeFileTarget

public SafeFileTarget(File file,
                      boolean append,
                      Formatter formatter)
            throws IOException
Construct file target to write to a file with a formatter.
Parameters:
file - the file to write to
append - true if file is to be appended to, false otherwise
formatter - the Formatter

Method Details

processEvent

public void processEvent(LogEvent event)
Process a log event, via formatting and outputting it.
Specified by:
processEvent in interface LogTarget
Overrides:
processEvent in interface AbstractTarget
Parameters:
event - the log event