Are logs drom dart:developer are visible in release mode of flutter app?

2.4k Views Asked by At

In release mode of flutter app, are console logs printed out with log method from dart:developer are visible? From docs of release mode we can read that

Debugging information is stripped out. Debugging is disabled.

and I assume it strip out everything printed with debugPrint method, but I couldn't found anything about log method.

Same goes for output with print method? Are those prints will be visible for user who will be reading device log output or not? Dart linter only says that print should be avoided in production code, I assume because of print output visibility.

Chapter in flutter docs about logging says how to use them but not really answer questions above.

2

There are 2 best solutions below

0
On BEST ANSWER

No, developer.log does not display information on the terminal when in release mode.

But print() will surely print all in any mode.

You can check that on android devices connected in USB, using adb logcat or adb logcat | grep flutter

Just be careful not to print large amounts of information with developers.log, as it won't truncate the string, as print actually does.

package: https://pub.dev/packages/dart_log

I actually created a package to handle logs(mentioned above), which allows you to define whether or not to print logs in release mode, and define the amount of characters that can be printed. all logs are linked to the file in exact line that logger was called, so you can click on it, and easily open the file that dispatched the log :)

0
On

Think of it this way. Use a logging library that sets up log trees. In the main function block of your app detect Release mode and have that log library remove the log tree which then makes sure no logs under release mode.

Fimber has such a log tree.