RotatingLogFileConfiguration
open class RotatingLogFileConfiguration: BasicLogConfiguration
A LogConfiguration
that uses an underlying RotatingLogFileRecorder
to
maintain a directory of log files that are rotated on a daily basis.
-
The filesystem path to a directory where the log files will be stored.
Declaration
Swift
open var directoryPath: String
-
Initializes a new
RotatingLogFileConfiguration
instance.Warning
The
RotatingLogFileRecorder
created by this configuration assumes full control over the log directory specified asdirectoryPath
. Any file not recognized as an active log file will be deleted during the automatic pruning process, which may occur at any time. Therefore, be extremely careful when constructing the value passed in as thedirectoryPath
.Declaration
Swift
public init(minimumSeverity: LogSeverity, daysToKeep: Int, directoryPath: String, synchronousMode: Bool = false, filters: [LogFilter] = [], formatters: [LogFormatter] = [ReadableLogFormatter()])
Parameters
minimumSeverity
The minimum supported
LogSeverity
. AnyLogEntry
having aseverity
less thanminimumSeverity
will be silently ignored by the configuration.daysToKeep
The number of days for which log files should be retained.
directoryPath
The filesystem path of the directory where the log files will be stored. Please note the warning above regarding the
directoryPath
.synchronousMode
Determines whether synchronous mode will be used by the underlying
RotatingLogFileRecorder
. Synchronous mode is helpful while debugging, as it ensures that logs are always up-to-date when debug breakpoints are hit. However, synchronous mode can have a negative influence on performance and is therefore not recommended for use in production code.filters
The
LogFilter
s to use when deciding whether a givenLogEntry
should be passed along for recording.formatters
An array of
LogFormatter
s to use for formatting log entries to be recorded by the receiver. Each formatter is consulted in sequence, and the formatted string returned by the first formatter to yield a non-nil
value will be recorded. If every formatter returnsnil
, the log entry is silently ignored and not recorded. -
Attempts to create—if it does not already exist—the directory indicated by the
directoryPath
property.Throws
If the function fails to create a directory atdirectoryPath
.Declaration
Swift
open func createLogDirectory() throws