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

public Class FileTarget

extends StreamTarget
Class Inheritance
Known Direct Subclasses
org.apache.log.output.io.SafeFileTarget, org.apache.log.output.io.rotate.RotatingFileTarget
Imports
java.io.File, .FileOutputStream, .IOException, org.apache.log.format.Formatter

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

Field Summary

Modifier and TypeField and Description
private boolean
private File

Constructor Summary

AccessConstructor and Description
public
FileTarget(final File
the file to write to
file
,
final boolean
true if file is to be appended to, false otherwise
append
,
final Formatter
the Formatter
formatter
)

Construct file target to write to a file with a formatter.

Method Summary

Modifier and TypeMethod and Description
protected synchronized File

Returns:

the output File
getFile
()

Retrieve file associated with target.

protected synchronized void
openFile()

Open underlying file and allocate resources.

protected synchronized void
setFile(final File
the file to write to
file
,
final boolean
true if file is to be appended to, false otherwise
append
)

Set the file for this target.

Inherited from org.apache.log.output.io.StreamTarget:
closesetOutputStreamshutdownStreamwrite

Field Detail

m_appendback to summary
private boolean m_append
m_fileback to summary
private File m_file

Constructor Detail

FileTargetback to summary
public FileTarget(final File file, final boolean append, final Formatter formatter) throws IOException

Construct file target to write to a file with a formatter.

Parameters
file:File

the file to write to

append:boolean

true if file is to be appended to, false otherwise

formatter:Formatter

the Formatter

Exceptions
IOException:
if an error occurs

Method Detail

getFileback to summary
protected synchronized File getFile()

Retrieve file associated with target. This allows subclasses to access file object.

Returns:File

the output File

openFileback to summary
protected synchronized 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.

Exceptions
IOException:
if directories can not be created or file can not be opened
setFileback to summary
protected synchronized void setFile(final File file, final boolean append) throws IOException

Set the file for this target.

Parameters
file:File

the file to write to

append:boolean

true if file is to be appended to, false otherwise

Exceptions
IOException:
if directories can not be created or file can not be opened