
Flutter's Logging Facilities
30 March, 2023
1
1
0
Contributors
Flutter has built-in logging support through the dart:developer
library, which provides several logging facilities that can be used to output messages to the console during development. These facilities include:
print()
: This is the simplest logging facility and can be used to output messages to the console using theprint()
function.debugPrint()
: This function works likeprint()
, but it only outputs messages when the app is running in debug mode.debugDumpApp()
: This function can be used to output a detailed tree of the widget hierarchy to the console, which can be helpful for debugging layout issues.debugDumpRenderTree()
: This function can be used to output a detailed tree of the rendering hierarchy to the console, which can be helpful for debugging rendering issues.debugDumpLayerTree()
: This function can be used to output a detailed tree of the compositing layers of the app, which can be helpful for debugging performance issues.
Additionally to the dart:developer
library, There are more advanced logging libraries like:
- logger : it's a simple, lightweight and extensible logging library for flutter.
- logging : A library for hierarchical, extensible logging. It allows you to output to console, file, memory or any other sink
- flutter_sentry : it's a flutter plugin that allows to send logs, events and reports to the Sentry.io
You can find more information on these and other logging facilities in the Flutter documentation:
- https://api.dart.dev/stable/2.9.2/dart-developer/dart-developer-library.html
- https://flutter.dev/docs/testing/errors
Using the logging view: