Skip to content

Instantly share code, notes, and snippets.

Created Jul 8, 2020
What would you like to do?
Flutter logging
import 'package:logging/logging.dart';
import 'dart:developer' as developer;
void initLogging() {
// disable hierarchical logger
hierarchicalLoggingEnabled = false;
// change to another level as needed.
Logger.root.level = Level.INFO;
// skip logging stactrace below the SEVERE level.
recordStackTraceAtLevel = Level.SEVERE;
assert(() {
recordStackTraceAtLevel = Level.WARNING;
// print all logs on debug build.
Logger.root.level = Level.ALL;
return true;
Logger.root.onRecord.listen((event) {
time: event.time,
sequenceNumber: event.sequenceNumber,
level: event.level.value,
name: event.loggerName,
error: event.error,
stackTrace: event.stackTrace,
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment