Flutter debugging release mode, enable logs in release mode
Asked Answered
H

4

23

I know based on documentation that

Debugging information is stripped out. Debugging is disabled.

But can we somehow force to print logs, or maybe debug in release mode? "production app" I'm using Android Studio.

For example while developing android app in AS we are able to print logs

android:debuggable="true"
Hobnail answered 26/10, 2020 at 12:51 Comment(0)
L
12

To check all available devices run flutter devices

Then run the below command to run the app in release mode with the logs
flutter run -d [deviceID] --release

Leda answered 7/9, 2023 at 7:58 Comment(0)
B
18

Plug your phone (if it is the case) on your computer and type on terminal:

$ flutter logs

You should be able to choose the device you want to see logs.

Breechloader answered 17/3, 2022 at 19:2 Comment(2)
This does not show anything for me. flutter logs Showing ELE L29 logs:Ailin
FWIW, looks like the behavior here is that it tails the logs, so you'd run this command, choose the device you want, then run your app on that deviceEnki
L
12

To check all available devices run flutter devices

Then run the below command to run the app in release mode with the logs
flutter run -d [deviceID] --release

Leda answered 7/9, 2023 at 7:58 Comment(0)
F
4

To display information that you would like to be visible in release mode ('production code') of your flutter app, simply use print() method. For info you want to hide in console log use debugPrint().

Maybe this part of documentation will help.

Faso answered 6/3, 2021 at 15:53 Comment(1)
using pring or debugprint in release (flutter run --release) on ios does not log anythingSteelwork
K
2

If you are using logger package, you must add a permissive filter, since the default one only prints on debug:

class PermissiveFilter extends logfilter {
  @override
  bool shouldlog(LogEvent event) => true;
}

var logger = logger(filter: PermissiveFilter());
Komsa answered 9/2 at 20:26 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.