FileLogger class

A logger that writes logs to a file asynchronously using an isolate.

This logger supports file rotation based on size.

Inheritance

Constructors

FileLogger({required String logFilePath, int maxFileSizeInBytes = 10 * 1024 * 1024, int maxBackupFiles = 5, Encoding encoding = utf8, int batchSize = 1, Duration flushInterval = const Duration(seconds: 2), LoggerFormatter? formatter, LoggerDateFormatter? dateFormatter})
Creates a new instance of FileLogger.

Properties

batchSize int
The number of log messages to buffer before writing to the file.
final
dateFormatter LoggerDateFormatter?
The date formatter for log messages.
getter/setter pairinherited
encoding Encoding
The encoding to use for writing to the file.
getter/setter pair
flushInterval Duration
The interval at which to flush the buffer to the file.
final
formatter LoggerFormatter
The formatter for log messages.
getter/setter pairinherited
hashCode int
The hash code for this object.
no setterinherited
id String
Unique identifier for the logger.
finalinherited
logFilePath String
The path to the log file.
final
maxBackupFiles int
The maximum number of backup files to keep.
final
maxFileSizeInBytes int
The maximum size of the log file in bytes before rotation.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

dispose() → void
Disposes the logger and releases any resources.
inherited
info(String message, String scope) → void
Logs an informational message. message is the log message. scope is the scope or context of the log.
inherited
log(Level level, String message, String scope, dynamic exception, StackTrace? stackTrace, LoggerFormatter formatter) → void
Writes a log entry. level is the severity level of the log. message is the log message. scope is the scope or context of the log. throwable is an optional error or exception associated with the log. stackTrace is an optional stack trace associated with the log. formatter is a function to format the log message.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
severe(String message, String scope, Exception? exception, StackTrace? stackTrace) → void
Logs a severe error message. message is the log message. scope is the scope or context of the log. exception is the associated exception. stackTrace is the associated stack trace.
inherited
shout(String message, String scope, Error? error, StackTrace? stackTrace) → void
Logs a shout message. message is the log message. scope is the scope or context of the log. error is the associated error. stackTrace is the associated stack trace.
inherited
toString() String
A string representation of this object.
inherited
warning(String message, String scope) → void
Logs a warning message. message is the log message. scope is the scope or context of the log.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited