Search packages, repositories and app categories

Package detailsv2.0.0+1

logging_appenders

Logging appenders for the dart logging package for print, file and remote (logz, loki, graylog (gelf)).

AndroidiOSmacOSWindowsLinux
30-day downloads
15.3K
Likes
44
Pub points
160

Install package

flutter pub add logging_appenders

Package Overview

Package selection guidance compiled from public package information, community data, and project usage.

A Flutter/Dart package that extends the core logging functionality by providing appenders for printing logs, writing to files, and sending logs remotely to services like Logz.io, Loki, and Graylog (GELF). It integrates seamlessly with the Dart logging package, enabling developers to route log messages through multiple destinations with minimal configuration. Ideal for debugging, monitoring, and centralized log management across environments.

Use cases

  • Debugging applications in development
  • Centralized log aggregation for production
  • Writing logs to local files for analysis
  • Sending logs to remote monitoring services
  • Real-time log streaming for observability

Key features

  • Supports print, file, and remote logging destinations
  • Integrates with popular log management platforms
  • Easy setup with the Dart logging package
  • Configurable log formatting and filtering
  • Cross-platform compatibility
  • Extensible architecture for custom appenders

Suitable for

  • Developers building cross-platform Flutter apps
  • Teams requiring centralized logging
  • Applications needing persistent log storage
  • DevOps engineers managing observability pipelines
  • Projects using structured logging with JSON output

Considerations

  • Requires proper configuration of remote service endpoints
  • File appender may impact performance if not managed
  • Remote logging introduces network dependency
  • Ensure sensitive data is not logged in production
  • May require additional dependencies for specific backends

Original README

Original README snapshot from the linked source repository. Visit the repository for the latest content.

logging_appenders

Pub codecov

Native dart package for logging appenders usable with the logging package.

Color Output Screenshot

It currently includes appenders for:

Performance of Remote Logging Appenders

I am not sure if it is wise to use this in production, but it's great during beta testing with a handful of users so you have all logs available.

It tries to stay reasonable performant by batching log entries and sending them off only every few seconds. If network is down it will retry later. (with an ever increasing interval).

Getting Started

After installing package logging and logging_appenders:

import 'package:logging/logging.dart';
import 'package:logging_appenders/logging_appenders.dart';

final _logger = Logger('main');

void main() {
  PrintAppender.setupLogging();

  // The above code is the same as:
  // Logger.root.level = Level.ALL;
  // PrintAppender()..attachToLogger(Logger.root);

  _logger.fine('Lorem ipsum');
}

Outputs:

$ dart main.dart
2019-08-19 15:36:03.827563 FINE main - Lorem ipsum

Support for Exception chaining

To chain exception you can use the extension method on Exception: causedBy().

int test() {
  try {
    int.parse('a');
  } catch (e, stackTrace) {
    throw Exception('unable to parse').causedBy(e, stackTrace);
  }
}
int main() {
  try {
    test();
  } catch (e, stackTrace) {
    logger.severe('catched Exception', e, stackTrace);
  }
}

Color Formatter

    PrintAppender(formatter: const ColorFormatter())
        ..attachToLogger(Logger.root);

Produces:

Color Output Screenshot

Logging to stderr

When using dart:io (ie. command line apps) it is possible to define which log levels should go to stderr instead of stdout:

PrintAppender.setupLogging(stderrLevel: Level.SEVERE);

Remote Appenders

Appender for logz.io

  final _logzIoApiSender = LogzIoApiAppender(
    // you can find your API key and the required URL from 
    // the logz.io dashboard: https://app-eu.logz.io/#/dashboard/settings/general
    apiToken: 'MY API KEY',
    url: 'https://listener-eu.logz.io:8071/',
    labels: {'app': 'MyApp', 'os': Platform.operatingSystem},
  );
  _logzIoApiSender.attachToLogger(Logger.root);
  
  
  // ...
  If you know that you no longer need the appender. it's good to dispose it:
  _logzIoApiSender.dispose();

Categories

Dependencies

Dependency list 5 items

Source repository

Projects using this package