jsonLoggerFormatter property
JSON log message formatter. Formats the log message as a JSON object with timestamp, level, scope, message, and exception if present.
Implementation
static LoggerFormatter jsonLoggerFormatter =
(LogContext context, LoggerDateFormatter? dateFormatter) {
final logMap = {
'timestamp': dateFormatter != null
? dateFormatter(context.timestamp)
: defaultJsonDateFormatter(context.timestamp),
'level': context.level.name,
'scope': context.scope,
'message': context.message,
'throwable': context.throwable?.toString(),
'stackTrace': context.stackTrace != null
? Trace.from(context.stackTrace!).terse.toString()
: null,
};
return jsonEncode(logMap);
};