public final class CalendarFileHandler extends StreamHandler implements TimerTaskListener
CalendarFileHandler deletes them.
This retention limit is configurable but defaults to 10 days.
The CalendarFileHandler uses three parameters to
generate the complete file name:
<base name>.<date pattern>.<extension>
Example: /var/log/app/app
The data pattern is passed to a
SimpleDateFormat.SimpleDateFormat(String). See
SimpleDateFormat for a detailed
explanation of valid date formats.
Example: log
Given the base name /var/log/eBus/eBus, a date
pattern "ddMMyyyy" and extension log, the
July 15, 2001 log file name is
/var/log/eBus/eBus.15072001.log
Configuration: CalendarFileHandler
default configuration uses the following LogManager
properties. If the named properties are either not defined or
have invalid values, then the default settings are used.
| Modifier and Type | Field and Description |
|---|---|
static String |
DEFAULT_BASENAME
The log file's default base name is "Logger".
|
static String |
DEFAULT_DATE_FORMAT
The log file's default data format is "yyyyMMdd".
|
static int |
DEFAULT_DAYS_KEPT
Log files are kept for 10 days by default.
|
static String |
DEFAULT_DIRECTORY
Log files are placed in the application's current working
directory by default.
|
static String |
DEFAULT_EXTENSION
The default file extension is "log".
|
static int |
MAX_DAYS_KEPT
The maximum number of days a log file is kept is 96.
|
static int |
MIN_DAYS_KEPT
The minimum number of days a log file is kept is 0.
|
| Constructor and Description |
|---|
CalendarFileHandler()
Creates a new
CalendarFileHandler and configures
it according to LogManager configuration
properties. |
CalendarFileHandler(String baseName,
String datePattern,
String extension,
int daysKept)
Creates a new
CalendarFileHandler instance for
the specified base name, date format pattern, file name
extension and how long to keep the files around. |
| Modifier and Type | Method and Description |
|---|---|
void |
handleTimeout(TimerEvent task)
Time to roll over to the next log file.
|
void |
publish(LogRecord record)
Flushes the output stream after
StreamHandler
publishes the log record. |
close, flush, isLoggable, setEncoding, setOutputStreamgetEncoding, getErrorManager, getFilter, getFormatter, getLevel, reportError, setErrorManager, setFilter, setFormatter, setLevelpublic static final String DEFAULT_DIRECTORY
public static final String DEFAULT_BASENAME
public static final String DEFAULT_DATE_FORMAT
public static final String DEFAULT_EXTENSION
public static final int MIN_DAYS_KEPT
public static final int MAX_DAYS_KEPT
public static final int DEFAULT_DAYS_KEPT
public CalendarFileHandler()
CalendarFileHandler and configures
it according to LogManager configuration
properties.public CalendarFileHandler(String baseName, String datePattern, String extension, int daysKept) throws IllegalArgumentException
CalendarFileHandler instance for
the specified base name, date format pattern, file name
extension and how long to keep the files around.baseName - where to put the log files.datePattern - date formatextension - file name extensiondaysKept - how long the log files are kept around
(in days).IllegalArgumentException - if:
baseName, datePattern or
extension is null.
baseName, datePattern or
extension is an empty string.
daysKept is < MIN_DAYS_KEPT
or > MAX_DAYS_KEPT.
datePattern is an invalid date format
pattern as per
java.text.SimpleDateFormat.
baseName is in an unknown directory or
directory cannot be accessed.
public void handleTimeout(TimerEvent task)
handleTimeout in interface TimerTaskListenertask - the roll file timer task.public void publish(LogRecord record)
StreamHandler
publishes the log record. StreamHandler does not
do this which means records are not seen in the log
file as they are published.publish in class StreamHandlerrecord - Publish this log record to the log file.Copyright © 2019. All rights reserved.