skip to Main Content

I released my app and unfortunately some errors are happening on customer devices. I am trying to understand it for solving but I couldn’t find a way to retrieve logs from a customer device.

Firebase Crashlytics is installed and logging uncaught exceptions but how can I retrieve all app-specific logs from device?

As I see iOS has added OSLogStore at iOS 15+ but there is no practical way to use from Flutter.

What solutions do you use to get recent logs from customer devices without telling your customer plugging their phones to Mac and running some commands on terminal. It can be automatic or remote controlled. Or from a button captioned "Send Device Logs".

2

Answers


  1. Usually, I log few details on Firebase Crashlytics and other internal information(thorough) on AWS CloudWatch for both PROD & DEV environment.

    Login or Signup to reply.
  2. It’s a common approach to create a centralized logging system which you only have to configure once on application startup. You can e.g. use dart’s own
    logging package and configure it differently for debug and release builds.

    import 'package:flutter/foundation.dart';
    
    if(kReleaseMode){ 
       Logger.root.level = Level.INFO; // is also the default
       Logger.root.onRecord.listen((record) {
          // Write to a file, to a server or use something like crashlytics
          FirebaseCrashlytics.instance.log('${record.level.name}: ${record.time}: ${record.message}');
       });
    } else {
       Logger.root.level = Level.ALL; 
       Logger.root.onRecord.listen((record) {
         print('${record.level.name}: ${record.time}: ${record.message}');
       });
    }
    

    Within your application, you can use it like this

    final log = Logger('MyClassName');
    log.info("Info message");
    log.warning("Warning");
    

    Of course, there is no need to use Crashlytics for that purpose. You can use any different remote logging solution or alternatively records everything to a file. For creating a file and writing to it, you can find more information in the documentation.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search