structured_logger 1.0.1-dev.0
structured_logger: ^1.0.1-dev.0 copied to clipboard
Structured logging for Dart with pluggable CLEF-compatible sinks.
structured_logger #
Structured logging for Dart with pluggable CLEF-compatible sinks.
This package provides an easy way to implement structured logs in Dart and Flutter applications. It allows sending logs to different destinations (terminal, Seq, etc.) through pluggable Sink interfaces.
Features #
- Pure Dart (works in CLI, servers, Flutter, etc.)
- Message templates with placeholders (e.g.
User {userId} logged in) - Multiple sinks: console, Seq (CLEF), custom
- Dio interceptor support (via companion package)
- Full CLEF / Seq compatibility
Installation #
dart pub add structured_logger
For Flutter:
flutter pub add structured_logger
Quick Start #
import 'package:structured_logger/structured_logger.dart';
final logger = StructureLogger()
..addSink(SimpleLineSink()); // console output
await logger.info('User {userId} did {action}', data: {
'userId': 42,
'action': 'checkout',
});
Sinks #
SimpleLineSink– human readable console logsSinkSeq– send to Seq (or any CLEF-compatible collector)- Custom sinks by implementing
LogSink
Example with Seq:
logger.addSink(SinkSeq(
'https://your-seq-server',
apiKey: 'your-key',
deviceIdentifier: 'my-app',
));
Documentation #
Full documentation, guides and API reference:
Related Packages #
- structured_logger_dio_interceptor – Dio HTTP logging
License #
MIT License. See LICENSE for details.