LogRecord class final

A LogRecord represents a single logging event captured by the logging system.

It holds metadata such as the log level, message, timestamp, error object, and stack trace. This structure allows loggers to format and route logs consistently and meaningfully.

This is particularly useful in diagnostic tools, analytics, and structured log processing.

Example usage:

final record = LogRecord(
  LogLevel.warning,
  'Something suspicious happened',
  loggerName: 'AuthService',
  error: InvalidFormatException('Invalid token'),
  stackTrace: StackTrace.current,
);
print(record);

Constructors

LogRecord(LogLevel level, String message, {String? loggerName, DateTime? time, Object? error, StackTrace? stackTrace})
A LogRecord represents a single logging event captured by the logging system.

Properties

error Object?
Optional object representing the error or exception that occurred.
final
hashCode int
The hash code for this object.
no setterinherited
level LogLevel
The severity level of the log message.
final
location String?
Gets the location information from the stack trace.
no setter
loggerName String?
An optional name for the logger that produced this record.
final
message String
The main log message.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
stackTrace StackTrace?
Optional stack trace associated with the error.
final
time DateTime
The timestamp indicating when this log record was created.
final

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
Returns a simple string representation of the log message.
override

Operators

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