comon_logger
Composable logging docs for Dart and Flutter with core, Flutter UI, HTTP, file, sharing, and navigation integrations.
comon_logger docs
comon_logger is a logging ecosystem for Dart and Flutter built around one shared model:
- named hierarchical loggers
- typed metadata on every record
- per-handler filters
- pluggable handlers and formatters
- optional integrations layered on top of the zero-dependency core
The ecosystem is split into focused packages so you can keep the core small and add UI, HTTP logging, file persistence, or sharing only where needed.
Package matrix
| Package | Use it for | When to add it |
|---|---|---|
comon_logger | Core logger, filters, handlers, formatters | Always start here |
comon_logger_otel | Export comon_logger records into OpenTelemetry logs with trace correlation | You already use comon_otel and want logs in the same observability pipeline |
comon_logger_flutter | In-app viewer and session history | You want to inspect logs inside a Flutter app |
comon_logger_dio | Dio interceptor and HTTP console formatter | You use Dio and want structured network logs |
comon_logger_dio_flutter | Rich HTTP cards in the Flutter viewer | You already log Dio requests into HistoryLogHandler |
comon_logger_file | Rotating file persistence | You need on-disk logs for backend or app diagnostics |
comon_logger_navigation_flutter | NavigatorObserver with structured route events | You want route transitions in the same logging pipeline |
comon_logger_share_flutter | Share/export action for the viewer | You need to export logs from a Flutter device |
comon_logger_devtools_extension | DevTools panel support | You want logs streamed into a custom DevTools tab |
Typical setups
Console only
Use comon_logger with ConsoleLogHandler.
Flutter app diagnostics
Use comon_logger + comon_logger_flutter, then add HTTP, share, and navigation packages as needed.
Backend or CLI service
Use comon_logger + comon_logger_file for console plus rotating disk output.
Unified observability
Use comon_logger + comon_logger_otel when the project already emits traces or metrics through comon_otel and logs should go to the same backend with active trace correlation.
Full mobile debugging stack
Use:
comon_loggercomon_logger_fluttercomon_logger_diocomon_logger_dio_fluttercomon_logger_navigation_fluttercomon_logger_share_flutter
Design rules
- Keep
Logger.rootas the aggregation point for app-wide handlers. - Use typed tags like
LogLayerandLogTypeinstead of encoding everything into the message. - Filter at the handler level so different outputs can keep different noise thresholds.
- Treat Flutter UI and DevTools integrations as optional consumers of the same structured records.
Getting started
Install the core package, attach a console handler, and emit the first records.
Core
Learn the record model, logger hierarchy, filters, handlers, and formatter pipeline.
OpenTelemetry
Bridge `comon_logger` records into `comon_otel` so logs, traces, and metrics share one pipeline.
Flutter
Add `HistoryLogHandler`, open the in-app viewer, and plug into DevTools.
Dio
Capture structured HTTP logs and render them in the console or Flutter UI.
File logging
Persist logs to rotating files with retention and optional JSON lines output.
Navigation
Record route transitions through `NavigatorObserver`.
Sharing
Export or share logs from the Flutter log viewer.
Recommended path
- Start with Getting started.
- Read Core to understand the data model and filter pipeline.
- Add OpenTelemetry if logs should leave the app as part of a broader observability pipeline.
- Add Flutter or Dio depending on your app shape.
- Add File logging, Navigation, and Sharing as focused extensions.