Linux build Code coverage Docs reference

Logger is an efficient structured logger for Dart.


The process of installation is very common and only requires pub to be installed on the machine.

$ pub get logger

Make sure you are running on Dart 2.0 or greater, as logger is currently limits support only to this platform.

Quick Start

Once package is installed on the machine you are ready to getting started, here is a quick example you can use:

import "dart:async" show Future;

import "package:logger/logger.dart" show Logger;
import "package:logger/handlers.dart" show ConsoleHandler;

void main() async {
  final logger = Logger.getLogger("example.console")

  final context = (logger.bind()
        ..string("username", "vanesyan")
        ..string("type", "image/png")
        ..string("image", "avatar.png"))

  final tracer = context.trace("uploading!");

  await Future<void>.delayed(const Duration(milliseconds: 1000));


The logger package comes with a bunch of log records handlers that are available at the handlers package entry; e.g. ConsoleHandler, FileHandler, etc.

By the way the logger package also exposes a default_logger entry which provides a top-level logger used to quick start.

import "dart:async" show Future;

import "package:logger/default_logger.dart" as log;
import "package:logger/handlers.dart" show ConsoleHandler;

void main() {
  log.addHandler(ConsoleHandler());"Hello world!");

Logger provided by the default_logger package entry shares the same API as the Logger available from logger package entry, with exception that the former cannot be closed.

You can find out more about API by following the link.


The source code is released under the terms of MIT license.