org.apache.log.output.io

Class FileTarget

Implemented Interfaces:
ErrorAware, LogTarget
Known Direct Subclasses:
RotatingFileTarget, SafeFileTarget

public class FileTarget
extends StreamTarget

A basic target that writes to a File.
Authors:
Avalon Development Team
Peter Donald

Field Summary

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

m_formatter

Constructor Summary

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

Method Summary

protected File
getFile()
Retrieve file associated with target.
protected void
openFile()
Open underlying file and allocate resources.
protected void
setFile(File file, boolean append)
Set the file for this target.

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

FileTarget

public FileTarget(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

getFile

protected File getFile()
Retrieve file associated with target. This allows subclasses to access file object.
Returns:
the output File

openFile

protected void openFile()
            throws IOException
Open underlying file and allocate resources. This method will attempt to create directories below file and append to it if specified.

setFile

protected void setFile(File file,
                       boolean append)
            throws IOException
Set the file for this target.
Parameters:
file - the file to write to
append - true if file is to be appended to, false otherwise