Jakub S.
Jakub S.

Reputation: 6080

Flutter debugging release mode, enable logs in release mode

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"

Upvotes: 25

Views: 28458

Answers (4)

Daniel Gomez Rico
Daniel Gomez Rico

Reputation: 15936

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());

Upvotes: 3

RITTIK
RITTIK

Reputation: 826

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

Upvotes: 15

Cícero Moura
Cícero Moura

Reputation: 2333

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.

Upvotes: 19

Paul Kastel
Paul Kastel

Reputation: 1147

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.

Upvotes: 5

Related Questions