java.lang.Object | |||
↳ | java.util.logging.Handler | ||
↳ | java.util.logging.StreamHandler | ||
↳ | java.util.logging.FileHandler |
A FileHandler
writes logging records into a specified file or a
rotating set of files.
When a set of files is used and a given amount of data has been written to one file, then this file is closed and another file is opened. The name of these files are generated by given name pattern, see below for details. When the files have all been filled the Handler returns to the first and goes through the set again.
By default, the I/O buffering mechanism is enabled, but when each log record is complete, it is flushed out.
XMLFormatter
is the default formatter for FileHandler
.
FileHandler
reads the following LogManager
properties for
initialization; if a property is not defined or has an invalid value, a
default value is used.
FileHandler
should append onto existing files, defaults to
false
.Filter
class
name, defaults to no Filter
.Formatter
class, defaults to java.util.logging.XMLFormatter
.Handler
, defaults to Level.ALL
.Name pattern is a string that may include some special substrings, which will be replaced to generate output files:
Normally, the generation numbers are not larger than the given file count and follow the sequence 0, 1, 2.... If the file count is larger than one, but the generation field("%g") has not been specified in the pattern, then the generation number after a dot will be added to the end of the file name.
The "%u" unique field is used to avoid conflicts and is set to 0 at first. If
one FileHandler
tries to open the filename which is currently in use
by another process, it will repeatedly increment the unique number field and
try again. If the "%u" component has not been included in the file name
pattern and some contention on a file does occur, then a unique numerical
value will be added to the end of the filename in question immediately to the
right of a dot. The generation of unique IDs for avoiding conflicts is only
guaranteed to work reliably when using a local disk file system.
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Construct a
FileHandler using LogManager properties or
their default value. | |||||||||||
Constructs a new
FileHandler . | |||||||||||
Construct a new
FileHandler . | |||||||||||
Construct a new
FileHandler . | |||||||||||
Construct a new
FileHandler . |
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Flushes and closes all opened files.
| |||||||||||
Publish a
LogRecord . |
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.util.logging.StreamHandler
| |||||||||||
From class
java.util.logging.Handler
| |||||||||||
From class
java.lang.Object
|
Construct a FileHandler
using LogManager
properties or
their default value.
IOException | if any I/O error occurs. |
---|
Constructs a new FileHandler
. The given name pattern is used as
output filename, the file limit is set to zero (no limit), the file count
is set to one; the remaining configuration is done using
LogManager
properties or their default values. This handler
writes to only one file with no size limit.
pattern | the name pattern for the output file. |
---|
IOException | if any I/O error occurs. |
---|---|
IllegalArgumentException | if the pattern is empty. |
NullPointerException | if the pattern is null .
|
Construct a new FileHandler
. The given name pattern is used as
output filename, the file limit is set to zero (no limit), the file count
is initialized to one and the value of append
becomes the new
instance's append mode. The remaining configuration is done using
LogManager
properties. This handler writes to only one file
with no size limit.
pattern | the name pattern for the output file. |
---|---|
append | the append mode. |
IOException | if any I/O error occurs. |
---|---|
IllegalArgumentException | if pattern is empty. |
NullPointerException | if pattern is null .
|
Construct a new FileHandler
. The given name pattern is used as
output filename, the maximum file size is set to limit
and the
file count is initialized to count
. The remaining configuration
is done using LogManager
properties. This handler is configured
to write to a rotating set of count files, when the limit of bytes has
been written to one output file, another file will be opened instead.
pattern | the name pattern for the output file. |
---|---|
limit | the data amount limit in bytes of one output file, can not be negative. |
count | the maximum number of files to use, can not be less than one. |
IOException | if any I/O error occurs. |
---|---|
IllegalArgumentException | if pattern is empty, limit < 0 or
count < 1 . |
NullPointerException | if pattern is null .
|
Construct a new FileHandler
. The given name pattern is used as
output filename, the maximum file size is set to limit
, the file
count is initialized to count
and the append mode is set to
append
. The remaining configuration is done using
LogManager
properties. This handler is configured to write to a
rotating set of count files, when the limit of bytes has been written to
one output file, another file will be opened instead.
pattern | the name pattern for the output file. |
---|---|
limit | the data amount limit in bytes of one output file, can not be negative. |
count | the maximum number of files to use, can not be less than one. |
append | the append mode. |
IOException | if any I/O error occurs. |
---|---|
IllegalArgumentException | if pattern is empty, limit < 0 or
count < 1 . |
NullPointerException | if pattern is null .
|
Publish a LogRecord
.
record | the log record to publish. |
---|