error function

void error(
  1. String message, [
  2. Map<String, dynamic> payload = const {},
  3. StackTrace? stackTrace
])

Logs message with LogSeverity.error severity.

Example:

try {
  throw Exception('Database connection failed');
} catch (e, stackTrace) {
  logger.error(
    'Failed to process transaction',
    {'transactionId': 'tx-999'},
    stackTrace,
  );
}

Implementation

void error(
  String message, [
  Map<String, dynamic> payload = const {},
  StackTrace? stackTrace,
]) => write(LogSeverity.error, message, payload, stackTrace);