Home > database >  How to see logs in release mode?
How to see logs in release mode?

Time:01-27

I need to see the logs in release mode. But I'm not able to see any output when I run the app with the command: flutter run --release.

How can I see the logs when app is running in the release mode?

CodePudding user response:

Open Android Studio with a dummy Android project (not Flutter). You'll find the Logcat pane on the bottom. That shows all the logs of all the apps running on your device. Filter by "flutter" and you should see logs of all Flutter apps running on that device.

A nice trick is, right before you do something interesting (launching the app, entering the risky page, doing whatever that creates the logs that you are looking for), clear the Logcat output and do that thing with the app to generate the log lines. Then scroll all the way up and find the logs that you were interested in. Sometimes Android exceptions may not show up with "flutter" in them and I found this technique to be very useful.

For iOS, the device console is what you are looking for: https://developer.apple.com/forums/thread/64123

CodePudding user response:

Use print() or debugPrint().

You have two options for logging for your application. The first is to use stdout and stderr. Generally, this is done using print() statements, or by importing dart:io and invoking methods on stderr and stdout.

If you output too much at once, then Android sometimes discards some log lines. To avoid this, use debugPrint(), from Flutter’s foundation library.

Check Debugging Flutter apps programmatically for more info.

The log tag will be "flutter" by the way.

  •  Tags:  
  • Related