org.apache.log.output.io
Class FileTarget
java.lang.Object
org.apache.log.output.AbstractTarget
org.apache.log.output.AbstractOutputTarget
org.apache.log.output.io.StreamTarget
org.apache.log.output.io.FileTarget
- All Implemented Interfaces:
- Closeable, ErrorAware, LogTarget
- Direct Known Subclasses:
- RotatingFileTarget, SafeFileTarget
- public class FileTarget
- extends StreamTarget
A basic target that writes to a File.
- Author:
- Avalon Development Team, Peter Donald
Constructor Summary |
FileTarget(java.io.File file,
boolean append,
Formatter formatter)
Construct file target to write to a file with a formatter. |
Method Summary |
protected java.io.File |
getFile()
Retrieve file associated with target. |
protected void |
openFile()
Open underlying file and allocate resources. |
protected void |
setFile(java.io.File file,
boolean append)
Set the file for this target. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
FileTarget
public FileTarget(java.io.File file,
boolean append,
Formatter formatter)
throws java.io.IOException
- Construct file target to write to a file with a formatter.
- Parameters:
file
- the file to write toappend
- true if file is to be appended to, false otherwiseformatter
- the Formatter
- Throws:
java.io.IOException
- if an error occurs
setFile
protected void setFile(java.io.File file,
boolean append)
throws java.io.IOException
- Set the file for this target.
- Parameters:
file
- the file to write toappend
- true if file is to be appended to, false otherwise
- Throws:
java.io.IOException
- if directories can not be created or file can not be opened
openFile
protected void openFile()
throws java.io.IOException
- Open underlying file and allocate resources.
This method will attempt to create directories below file and
append to it if specified.
- Throws:
java.io.IOException
- if directories can not be created or file can not be opened
getFile
protected java.io.File getFile()
- Retrieve file associated with target.
This allows subclasses to access file object.
- Returns:
- the output File
Copyright © 1997-2005 The Apache Software Foundation. All Rights Reserved.