Logger class abstract interface

Logger is used to emit logging messages.

There are three types of Logger:

  1. Hierarchical logger: Named logger using dot-separated namespaces.
  2. Detached logger: Optionally named logger not part of any logger hierarchy.
  3. Noop logger: Logger that does nothing.

Obtain Logger objects using:

Each logger has:

  • A severity level (Logger.level) defining the minimum severity it handles.
  • An optional filter (Logger.filter) to further refine which messages are logged.

Use Logger.log or its derivatives (Logger.debug, Logger.info, etc.) to log messages. The logger checks:

  1. Severity level
  2. Filter (if any)
  3. Delegates to the registered handler (if any, see Logger.handler)

Use Logger.withFields to bind structured data to the logging context.

Implemented types
Implementers
Available extensions

Constructors

Logger.detached([String? name])
Creates a new detached logger.
factory
Logger.getLogger(String name)
Retrieves or creates a logger with the given name.
factory
Logger.noop()
Creates a new noop logger which never emits logs or delegates records to handlers.
factory

Properties

filter Filter?
Sets this logger's filter.
no getter
handler Handler?
Sets this logger's handler.
no getter
hashCode int
The hash code for this object.
no setterinherited
level Level
Gets the minimum severity level of Records this logger handles.
getter/setter pair
name String?
Name of this logger.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

debug(String message, [Iterable<Field>? fields]) → void

Available on Interface, provided by the DefaultLog extension

Emits a record with message and Level.debug severity level.
error(String message, [Iterable<Field>? fields]) → void

Available on Interface, provided by the DefaultLog extension

Emits a record with message and Level.error severity level.
fatal(String message, [Iterable<Field>? fields]) → void

Available on Interface, provided by the DefaultLog extension

Emits a record with message and Level.fatal severity level.
info(String message, [Iterable<Field>? fields]) → void

Available on Interface, provided by the DefaultLog extension

Emits a record with message and Level.info severity level.
isEnabledFor(Level level) bool
Checks if a record with the given severity level will be emitted by this logger.
log(Level level, String message, [Iterable<Field>? fields]) → void
Emits a record with message and level severity level.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
startTimer(String message, {Level level = Level.info}) Timer
Starts tracing and emits a record with message and level severity level; to stop tracing call Timer.stop on the returned timer.
inherited
toString() String
A string representation of this object.
inherited
warn(String message, [Iterable<Field>? fields]) → void

Available on Interface, provided by the DefaultLog extension

Emits a record with message and Level.warn severity level.
withFields(Iterable<Field> fields) Interface
Creates and returns a new logging context with bound collection of fields added to existing ones.
inherited

Operators

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

Static Properties

root Logger
The root logger, representing the topmost logger in the hierarchy.
no setter