|
Final | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.util.logging.Handler
java.util.logging.StreamHandler
java.util.logging.FileHandler
public class FileHandler
A FileHandler is a Handler that writes logging events to one
or more files.
If multiple files are used, when a given amount of data has been written to one file, this file is closed, and the next file is opened. The names of these files are generated by the given name pattern, see below for details. When all the files have all been filled the Handler returns to the first one and goes through the set again.
FileHandler defines the following configuration properties,
which are read by the LogManager on initialization. If the
properties have not been specified then defaults will be used. The properties
and defaults are as follows:
FileHandler appends to a file's existing content, if false it
overwrites it. Default is false.Filter class. No Filter is used by default.Formatter class. Default is
java.util.logging.XMLFormatter.Handler. Default is Level.ALL.The name pattern is a String that can contain some of the following sub-strings, which will be replaced to generate the output file names:
The generation numbers, denoted by "%g" in the filename pattern will be created in ascending numerical order from 0, i.e. 0,1,2,3... If "%g" was not present in the pattern and more than one file is being used then a dot and a generation number is appended to the filename at the end. This is equivalent to appending ".%g" to the pattern.
The unique identifier, denoted by "%u" in the filename pattern will always be
0 unless the FileHandler is unable to open the file. In that
case 1 is tried, then 2, and so on until a file is found that can be opened.
If "%u" was not present in the pattern but a unique number is required then a
dot and a unique number is added to the end of the filename, equivalent to
appending ".%u" to the pattern.
| Constructor Summary | |
|---|---|
FileHandler()
Construct a FileHandler using LogManager
properties or their default value |
|
FileHandler(String pattern)
Construct a FileHandler, the given name pattern is used
as output filename, the file limit is set to zero(no limit), and the file
count is set to one, other configuration using LogManager
properties or their default value
This handler write to only one file and no amount limit. |
|
FileHandler(String pattern,
boolean append)
Construct a FileHandler, the given name pattern is used
as output filename, the file limit is set to zero(i.e. no limit applies),
the file count is initialized to one, and the value of
append becomes the new instance's append mode. |
|
FileHandler(String pattern,
int limit,
int count)
Construct a FileHandler, the given name pattern is used
as output filename, the file limit is set to given limit argument, and
the file count is set to given count argument, other configuration using
LogManager properties or their default value
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. |
|
FileHandler(String pattern,
int limit,
int count,
boolean append)
Construct a FileHandler, the given name pattern is used
as output filename, the file limit is set to given limit argument, the
file count is set to given count argument, and the append mode is set to
given append argument, other configuration using LogManager
properties or their default value
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. |
|
| Method Summary | |
|---|---|
void |
close()
Flush and close all opened files. |
void |
publish(LogRecord record)
Publish a LogRecord |
| Methods inherited from class java.util.logging.StreamHandler |
|---|
flush, isLoggable, setEncoding, setOutputStream |
| Methods inherited from class java.util.logging.Handler |
|---|
getEncoding, getErrorManager, getFilter, getFormatter, getLevel, reportError, setErrorManager, setFilter, setFormatter, setLevel |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public FileHandler()
throws IOException
FileHandler using LogManager
properties or their default value
IOException - if any IO exception happened
SecurityException - if security manager exists and it determines that caller does
not have the required permissions to control this handler,
required permissions include
LogPermission("control") and other permission
like FilePermission("write"), etc.public FileHandler(String pattern)
throws IOException
FileHandler, the given name pattern is used
as output filename, the file limit is set to zero(no limit), and the file
count is set to one, other configuration using LogManager
properties or their default value
This handler write to only one file and no amount limit.
pattern - the name pattern of output file
IOException - if any IO exception happened
SecurityException - if security manager exists and it determines that caller does
not have the required permissions to control this handler,
required permissions include
LogPermission("control") and other permission
like FilePermission("write"), etc.
NullPointerException - if the pattern is null.
IllegalArgumentException - if the pattern is empty.public FileHandler(String pattern,
boolean append)
throws IOException
FileHandler, the given name pattern is used
as output filename, the file limit is set to zero(i.e. no limit applies),
the file count is initialized to one, and the value of
append becomes the new instance's append mode. Other
configuration is done using LogManager properties.
This handler write to only one file and no amount limit.
pattern - the name pattern of output fileappend - the append mode
IOException - if any IO exception happened
SecurityException - if security manager exists and it determines that caller does
not have the required permissions to control this handler,
required permissions include
LogPermission("control") and other permission
like FilePermission("write"), etc.
NullPointerException - if the pattern is null.
IllegalArgumentException - if the pattern is empty.public FileHandler(String pattern,
int limit,
int count)
throws IOException
FileHandler, the given name pattern is used
as output filename, the file limit is set to given limit argument, and
the file count is set to given count argument, other configuration using
LogManager properties or their default value
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 of output filelimit - the data amount limit in bytes of one output file, cannot less
than onecount - the maximum number of files can be used, cannot less than one
IOException - if any IO exception happened
SecurityException - if security manager exists and it determines that caller does
not have the required permissions to control this handler,
required permissions include
LogPermission("control") and other permission
like FilePermission("write"), etc.
NullPointerException - if pattern is null.
IllegalArgumentException - if count<1, or limit<0public FileHandler(String pattern,
int limit,
int count,
boolean append)
throws IOException
FileHandler, the given name pattern is used
as output filename, the file limit is set to given limit argument, the
file count is set to given count argument, and the append mode is set to
given append argument, other configuration using LogManager
properties or their default value
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 of output filelimit - the data amount limit in bytes of one output file, cannot less
than onecount - the maximum number of files can be used, cannot less than oneappend - the append mode
IOException - if any IO exception happened
SecurityException - if security manager exists and it determines that caller does
not have the required permissions to control this handler,
required permissions include
LogPermission("control") and other permission
like FilePermission("write"), etc.
NullPointerException - if pattern is null.
IllegalArgumentException - if count<1, or limit<0| Method Detail |
|---|
public void close()
close in class StreamHandlerSecurityException - if security manager exists and it determines that caller does
not have the required permissions to control this handler,
required permissions include
LogPermission("control") and other permission
like FilePermission("write"), etc.public void publish(LogRecord record)
LogRecord
publish in class StreamHandlerrecord - the log record to be published
|
Final | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||