logging 0.11.3+1

  • README.md
  • Installing
  • Versions
  • 89


By default, the logging package does not do anything useful with the log messages. You must configure the logging level and add a handler for the log messages.

Here is a simple logging configuration that logs all messages via print.

Logger.root.level = Level.ALL;
Logger.root.onRecord.listen((LogRecord rec) {
  print('${rec.level.name}: ${rec.time}: ${rec.message}');

First, set the root [Level]. All messages at or above the level are sent to the [onRecord] stream.

Then, listen on the [onRecord] stream for [LogRecord] events. The [LogRecord] class has various properties for the message, error, logger name, and more.

Logging messages

Create a [Logger] with a unique name to easily identify the source of the log messages.

final Logger log = new Logger('MyClassName');

Here is an example of logging a debug message and an error:

var future = doSomethingAsync().then((result) {
  log.fine('Got the result: $result');
}).catchError((e, stackTrace) => log.severe('Oh noes!', e, stackTrace));

When logging more complex messages, you can pass a closure instead that will be evaluated only if the message is actually logged:

log.fine(() => [1, 2, 3, 4, 5].map((e) => e * 4).join("-"));

See the [Logger] class for the different logging methods.


  • Fixed several documentation comments.


  • Added optional LogRecord.object field.

  • Logger.log sets LogRecord.object if the message is not a string or a function that returns a string. So that a handler can access the original object instead of just its toString().


  • Added Logger.detached - a convenience factory to obtain a logger that is not attached to this library's logger hierarchy.


  • Include default error with the auto-generated stack traces.


  • Add support for automatically logging the stack trace on error messages. Note this can be expensive, so it is off by default.


  • Revert change in 0.10.0. stackTrace must be an instance of StackTrace. Use the Trace class from the stack_trace package to convert strings.


  • Change type of stackTrace from StackTrace to Object.


  • Added optional LogRecord.zone field.

  • Record current zone (or user specified zone) when creating new LogRecords.

1. Depend on it

Add this to your package's pubspec.yaml file:

  logging: "^0.11.3+1"

2. Install it

You can install packages from the command line:

with pub:

$ pub get

with Flutter:

$ flutter packages get

Alternatively, your editor might support pub get or packages get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:logging/logging.dart';
Version Uploaded Documentation Archive
0.11.3+1 Jul 18, 2016 Go to the documentation of logging 0.11.3+1 Download logging 0.11.3+1 archive
0.11.3 Apr 20, 2016 Go to the documentation of logging 0.11.3 Download logging 0.11.3 archive
0.11.2 Oct 1, 2015 Go to the documentation of logging 0.11.2 Download logging 0.11.2 archive
0.11.1+1 Aug 19, 2015 Go to the documentation of logging 0.11.1+1 Download logging 0.11.1+1 archive
0.11.1 May 7, 2015 Go to the documentation of logging 0.11.1 Download logging 0.11.1 archive
0.11.0 May 6, 2015 Go to the documentation of logging 0.11.0 Download logging 0.11.0 archive
0.10.0 Apr 10, 2015 Go to the documentation of logging 0.10.0 Download logging 0.10.0 archive
0.9.3 Jan 7, 2015 Go to the documentation of logging 0.9.3 Download logging 0.9.3 archive
0.9.2 Jul 25, 2014 Go to the documentation of logging 0.9.2 Download logging 0.9.2 archive
0.9.1+2 Jul 24, 2014 Go to the documentation of logging 0.9.1+2 Download logging 0.9.1+2 archive

All 94 versions...


This feature is new.
We welcome feedback.
More details: scoring.

We analyzed this package, and provided a score, details, and suggestions below.

  • completed on Jan 21, 2018
  • Dart: 2.0.0-dev.15.0
  • pana: 0.10.0


Describes how popular the package is relative to other packages. [more]
99 / 100
Code health derived from static analysis. [more]
100 / 100
Reflects how tidy and up-to-date the package is. [more]
49 / 100
Overall score:
Weighted score of the above. [more]


Detected platforms: Flutter, web, other

No platform restriction found in primary library package:logging/logging.dart.


  • Package is pre-v1 release.

    While there is nothing inherently wrong with versions of 0.*.*, it usually means that the author is still experimenting with the general direction API.

  • The description is too long.

    Search engines will display only the first part of the description. Try to keep it under 180 characters.

  • Maintain an example.

    Create a short demo in the example/ directory to show how to use this package. Common file name patterns include: main.dart, example.dart or you could also use logging.dart.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.5.0 <2.0.0
Dev dependencies
test >=0.12.0 <0.13.0