AbstractTimeBasedPolicy
, CountPolicy
, DailyPolicy
, HourlyPolicy
, MonthlyPolicy
, SizePolicy
, StartupPolicy
, WeeklyPolicy
, YearlyPolicy
public interface Policy
RollingFileWriter
.
The annotation PropertiesSupport
must be added to the implemented
policy class and the implemented policy must be registered as service in "META-INF/services/org.pmw.tinylog.policies"
in order to make the policy available by properties files and system properties.
Example:
@PropertiesSupport(name = "startup")
public final class StartupPolicy implements Policy {
A policy must have a default constructor without any parameters. Optionally it can have an additional constructor with a string parameter if the policy supports parameters.
Modifier and Type | Method | Description |
---|---|---|
boolean |
check(File logFile) |
Determine whether a log file can be continued.
|
boolean |
check(String logEntry) |
Determine whether a log entry can be written into the current log file.
|
void |
init(Configuration configuration) |
Initialize the policy.
|
void |
reset() |
The log file was rolled and reset the policy.
|
void init(Configuration configuration)
configuration
- Configuration of loggerboolean check(File logFile) throws IOException
logFile
- Log file to continuetrue
to continue the log file, false
to trigger a rolloverIOException
- Failed to handle log fileboolean check(String logEntry)
logEntry
- Log entry to writetrue
to continue the current log file, false
to trigger a rollovervoid reset()
Copyright © 2019. All rights reserved.