public class ArchivingFileHandler extends AbstractStreamHandler
Intially, if the "current log file" exists, it renames it (or, if it already exists and the "append" option is
true
, opens it in "append" mode).
Initially, the "current log file" is renamed and re-created and log records are written to it. When it is time to "archive" the current log file, then it is closed, renamed and re-created.
Modifier and Type | Field and Description |
---|---|
static boolean |
DEFAULT_APPEND |
static String |
DEFAULT_PATTERN |
static long |
DEFAULT_SIZE_LIMIT |
static TimeTable |
DEFAULT_TIME_TABLE |
static long |
NO_LIMIT
A special value for the sizeLimit paramter of
ArchivingFileHandler(String,
long, TimeTable, boolean, boolean, Level, Filter, Formatter, String) indicating that no limit should apply. |
DEFAULT_AUTO_FLUSH, DEFAULT_ENCODING, DEFAULT_FILTER, DEFAULT_FORMATTER, DEFAULT_LEVEL
Modifier and Type | Method and Description |
---|---|
void |
publish(LogRecord record) |
close, flush, isLoggable, setEncoding, setOutputStream
getEncoding, getErrorManager, getFilter, getFormatter, getLevel, reportError, setErrorManager, setFilter, setFormatter, setLevel
public static final long NO_LIMIT
ArchivingFileHandler(String,
long, TimeTable, boolean, boolean, Level, Filter, Formatter, String)
indicating that no limit should apply.public static final String DEFAULT_PATTERN
public static final long DEFAULT_SIZE_LIMIT
public static final TimeTable DEFAULT_TIME_TABLE
public static final boolean DEFAULT_APPEND
public ArchivingFileHandler() throws ParseException, EvaluationException, IOException
LogManager
).
The ArchivingFileHandler
, like all java.util.logging
handlers, initializes itself with a set of
"logging properties" which it retrieves through the LogManager
, which normally reads them from the
"logging.properties
" file:
.pattern
ArchivingFileHandler(String, long, TimeTable, boolean, boolean, Level, Filter, Formatter, String)
.
Defaults to "%h/java%d.log".
.sizeLimit
.timeTable
TimeTable
for log file archiving with this syntax
.
Defaults to "never".
de.unkrig.commons.util.TimeTable.parse("*:0")
" for "every full hour".
.append
false
.
protected ArchivingFileHandler(int dummy, @Nullable String propertyNamePrefix) throws ParseException, EvaluationException, IOException
ArchivingFileHandler()
.dummy
- Only there to distinguish this constructor from ArchivingFileHandler(String)
propertyNamePrefix
- The property name prefix, or null
to use the qualified name of the
actual handler classParseException
EvaluationException
IOException
public ArchivingFileHandler(String pattern) throws IOException
ArchivingFileHandler(
pattern,
DEFAULT_SIZE_LIMIT
,
DEFAULT_TIME_TABLE
,
false,
true,
AbstractStreamHandler.DEFAULT_LEVEL
,
AbstractStreamHandler.DEFAULT_FILTER
,
AbstractStreamHandler.DEFAULT_FORMATTER
,
AbstractStreamHandler.DEFAULT_ENCODING
)
.IOException
public ArchivingFileHandler(String pattern, boolean append) throws IOException
ArchivingFileHandler(
pattern,
9223372036854775807L,
DEFAULT_TIME_TABLE
,
append,
true,
AbstractStreamHandler.DEFAULT_LEVEL
,
AbstractStreamHandler.DEFAULT_FILTER
,
AbstractStreamHandler.DEFAULT_FORMATTER
,
AbstractStreamHandler.DEFAULT_ENCODING
)
.IOException
public ArchivingFileHandler(String pattern, long sizeLimit) throws IOException
ArchivingFileHandler(
pattern,
sizeLimit,
DEFAULT_TIME_TABLE
,
false,
true,
AbstractStreamHandler.DEFAULT_LEVEL
,
AbstractStreamHandler.DEFAULT_FILTER
,
AbstractStreamHandler.DEFAULT_FORMATTER
,
AbstractStreamHandler.DEFAULT_ENCODING
)
.IOException
public ArchivingFileHandler(String pattern, long sizeLimit, boolean append) throws IOException
ArchivingFileHandler(
pattern,
sizeLimit,
DEFAULT_TIME_TABLE
,
append,
true,
AbstractStreamHandler.DEFAULT_LEVEL
,
AbstractStreamHandler.DEFAULT_FILTER
,
AbstractStreamHandler.DEFAULT_FORMATTER
,
AbstractStreamHandler.DEFAULT_ENCODING
)
.IOException
public ArchivingFileHandler(String pattern, TimeTable timeTable) throws IOException
ArchivingFileHandler(
pattern,
9223372036854775807L,
timeTable,
false,
true,
AbstractStreamHandler.DEFAULT_LEVEL
,
AbstractStreamHandler.DEFAULT_FILTER
,
AbstractStreamHandler.DEFAULT_FORMATTER
,
AbstractStreamHandler.DEFAULT_ENCODING
)
.IOException
public ArchivingFileHandler(String pattern, TimeTable timeTable, boolean append) throws IOException
ArchivingFileHandler(
pattern,
9223372036854775807L,
timeTable,
append,
true,
AbstractStreamHandler.DEFAULT_LEVEL
,
AbstractStreamHandler.DEFAULT_FILTER
,
AbstractStreamHandler.DEFAULT_FORMATTER
,
AbstractStreamHandler.DEFAULT_ENCODING
)
.IOException
public ArchivingFileHandler(String pattern, long sizeLimit, TimeTable timeTable, boolean append, boolean autoFlush, Level level, @Nullable Filter filter, Formatter formatter, @Nullable String encoding) throws IOException
%%
"%"
%h
user.home
" system property)%t
java.io.tmpdir
" system property)%d
DateFormat
_yyyy-MM-dd_HH-mm-ss
. For the
"current log file", "%d
" is replaced with the empty string.
%d
" placeholder, then "%d
" is silently appended to the
pattern.
pattern
- See the method description
sizeLimit
- The size limit for the current filetimeTable
- The time table for time-based archivingappend
- Whether to append to the current log file (if it initially exists)autoFlush
- See StreamHandler.StreamHandler(OutputStream, boolean, Level, Filter, Formatter, String)
level
- See StreamHandler.StreamHandler(OutputStream, boolean, Level, Filter, Formatter, String)
filter
- See StreamHandler.StreamHandler(OutputStream, boolean, Level, Filter, Formatter, String)
formatter
- See StreamHandler.StreamHandler(OutputStream, boolean, Level, Filter, Formatter, String)
encoding
- See StreamHandler.StreamHandler(OutputStream, boolean, Level, Filter, Formatter, String)
IOException
public void publish(@Nullable LogRecord record)
publish
in class AbstractStreamHandler
Copyright © 2018 Arno Unkrig. All rights reserved.