public class FileHandler extends WriterHandler
| Modifier and Type | Field and Description |
|---|---|
protected boolean |
fileAppend
Controls file truncatation.
|
protected String |
fileName
The name of the log file.
|
bufferedIO, bufferSize, immediateFlushname| Constructor and Description |
|---|
FileHandler()
The default constructor does not do anything.
|
FileHandler(Formatter layout,
String filename)
Instantiate a FileHandler and open the file designated by
filename. |
FileHandler(Formatter layout,
String filename,
boolean append)
Instantiate a FileHandler and open the file designated by
filename. |
FileHandler(Formatter layout,
String filename,
boolean append,
boolean bufferedIO,
int bufferSize)
Instantiate a
FileHandler and open the file designated by
filename. |
| Modifier and Type | Method and Description |
|---|---|
void |
activateOptions()
If the value of File is not
null, then setFile(String) is called with the values of File and
Append properties. |
boolean |
getAppend()
Returns the value of the Append option.
|
String |
getFile()
Returns the value of the File option.
|
void |
setAppend(boolean flag)
The Append option takes a boolean value.
|
void |
setFile(String file)
The File property takes a string value which should be the name of
the file to append to.
|
void |
setFile(String fileName,
boolean append,
boolean bufferedIO,
int bufferSize)
Sets and opens the file where the log output will go.
|
checkEntryConditions, close, flush, getBufferSize, getImmediateFlush, isBufferedIO, publish, setBufferedIO, setBufferSize, setEncoding, setImmediateFlush, setOutputStream, subPublishdebug, getName, setNamegetEncoding, getErrorManager, getFilter, getFormatter, getLevel, isLoggable, reportError, setErrorManager, setFilter, setFormatter, setLevelprotected boolean fileAppend
true, meaning that by default a FileAppender
will append to an existing file and not truncate it.
This option is meaningful only if the FileAppender opens the file.protected String fileName
public FileHandler()
public FileHandler(Formatter layout, String filename, boolean append, boolean bufferedIO, int bufferSize) throws IOException
FileHandler and open the file designated by
filename. The opened filename will become the output
destination for this appender.
If the append
parameter is true, the file will be appended to. Otherwise, the file
designated by filename will be truncated before being
opened.
If the bufferedIO parameter is
true, then buffered IO will be used to write to the output
file.layout - The formatter for the log recordfilename - The base file name for the log fileappend - The append mode to use for the log filebufferedIO - Flag indicating whether IO should be bufferedbufferSize - The buffer size to use if using buffered IOIOException - If errors are encountered while setting up the logging systempublic FileHandler(Formatter layout, String filename, boolean append) throws IOException
filename. The opened filename will become the output
destination for this appender.
If the append
parameter is true, the file will be appended to. Otherwise, the file
designated by filename will be truncated before being
opened.layout - The formatter to use for the log recordsfilename - The base log file nameappend - The append mode to use for the log fileIOException - If errors are encountered while setting up the logging systempublic FileHandler(Formatter layout, String filename) throws IOException
filename. The opened filename will become the output
destination for this appender.
The file will be appended to.layout - The formatter to use for the log recordsfilename - The base log file nameIOException - If errors are encountered while setting up the logging systempublic void setFile(String file)
activateOptions() is called, not when the options are set.file - The file to append topublic boolean getAppend()
public String getFile()
public void activateOptions()
null, then setFile(String) is called with the values of File and
Append properties.activateOptions in class HandlerSkeletonpublic void setAppend(boolean flag)
true by default. If true, then File will be
opened in append mode by setFile (see above).
Otherwise, setFile will open File
in truncate mode.
Note: Actual opening of the file is made when
activateOptions() is called, not when the options are set.flag - The flag that indicates append modepublic void setFile(String fileName, boolean append, boolean bufferedIO, int bufferSize) throws IOException
fileName - The path to the log file.append - If true will append to fileName. Otherwise will
truncate fileName.bufferedIO - Flag indicating whether IO operations should be bufferedbufferSize - The buffer size to use when using buffered IOIOException - If errors are encountered