configure static method
void
configure(})
Configures a logger's properties, updating the config in-place.
Intentions: Sets or updates logger configs. Unspecified parameters retain previous/existing values. Affects logger and it's logger tree descendants where not explicitly set; use freezeInheritance() on any point on Logger tree to freeze current branch/leaf state. Note: Names are case-insensitive and normalized to lowercase.
Parameters:
name: The logger name to configure (case-insensitive).enabled: Whether logging is enabled.logLevel: Minimum log level to process.includeFileLineInHeader: Include file/line in origin.stackMethodCount: Stack frames per level. Values must be non-negative.timestamp: Timestamp config.stackTraceParser: Stack parser config.handlers: List of handlers. Must not be empty if provided.autoSinkBuffer: Whether to auto-sink abandoned buffers.
Throws ArgumentError if:
- Any
stackMethodCountvalue is negative. handlersis an empty list.
How to use:
- Logger.configure('app', logLevel: LogLevel.info);
- Changes are immediate and dynamically inherited down Logger tree hierarchy where not explicitly set.
Example: Logger.configure('global', enabled: false); // Disables all Loggers, except enabled explicitly.
Implementation
static void configure(
final String name, {
final bool? enabled,
final LogLevel? logLevel,
final bool? includeFileLineInHeader,
final Map<LogLevel, int>? stackMethodCount,
final Timestamp? timestamp,
final StackTraceParser? stackTraceParser,
final List<Handler>? handlers,
final bool? autoSinkBuffer,
}) {
configureMultiple({
name: LoggerConfig(
enabled: enabled,
logLevel: logLevel,
includeFileLineInHeader: includeFileLineInHeader,
stackMethodCount: stackMethodCount,
timestamp: timestamp,
stackTraceParser: stackTraceParser,
handlers: handlers,
autoSinkBuffer: autoSinkBuffer,
),
});
}