Logging Integration

The sentry_logging library provides Logging support for Sentry using the onRecord property. It is able to collect breadcrumbs and capture events. Once this integration is configured, you can use Logging’s public API exclusively or in combination to the Sentry's SDK API to capture and enrich events.

The source can be found on GitHub.

To add the Logging integration, add the sentry_logging dependency.

  sentry: ^7.20.0
  sentry_logging: ^7.20.0
  logging: ^1.0.2

Configuration should happen as early as possible in your application's lifecycle.

import 'package:sentry_logging/sentry_logging.dart';
import 'package:sentry/sentry.dart';

Future<void> main() async {
  await Sentry.init(
    (options) {
      options.dsn = 'https://examplePublicKey@o0.ingest.sentry.io/0';
    appRunner: initApp, // Init your App.

This snippet captures an intentional error, so you can test that everything is working as soon as you set it up:

import 'package:logging/logging.dart';

void main() async {
  final log = Logger('MyAwesomeLogger');

  log.info('a breadcrumb!');

  try {
    throw Exception();
  } catch (error, stackTrace) {
    log.severe('an error!', error, stackTrace);

To view and resolve the recorded message, log into sentry.io and open your project. Clicking on the error's title will open a page where you can see detailed information and mark it as resolved.

Help improve this content
Our documentation is open source and available on GitHub. Your contributions are welcome, whether fixing a typo (drat!) or suggesting an update ("yeah, this would be better").