Name
FileHandler
Synopsis
This
Handler subclass formats
LogRecord objects and outputs the resulting
strings to a file or to a rotating set of files. Arguments passed to
the FileHandler( ) constructor specify which file
or files are used, and how they are used. The arguments are optional,
and if they are not specified, defaults are obtained through
LogManager.getProperty( ) as described below. The
constructor arguments are:
-
pattern A string containing substitution characters that describes one or more files to use. The substitutions performed to convert this pattern to a filename are described below.
-
limit An approximate maximum file size for the log file, or 0 for no limit. If
countis set to greater than one, then when a log file reaches this maximum,FileHandlercloses it, renames it, and then starts a new log with the original filename.-
count When
limitis set to be nonzero, this arguemnt specifies the number of old log files to retain.-
append trueif theFileHandlershould append to log messages already in the named file, orfalseif it should overwrite the file.
The pattern argument is the most important
of these: it specifies which file or files the
FileHandler will write to.
FileHandler performs the following substitutions
on the specified pattern to convert it to a filename:
|
For |
Substitute |
|---|---|
|
|
The directory separator character for the platform. This means that you can always use a forward slash in your patterns, even on Windows filesystems that use backward slashes. |
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access