Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Questions] - How to send error level logs in crashlytics ? #138

Open
kristijorgji opened this issue May 13, 2022 · 4 comments
Open

[Questions] - How to send error level logs in crashlytics ? #138

kristijorgji opened this issue May 13, 2022 · 4 comments

Comments

@kristijorgji
Copy link

Hi, I would like to know if it is possible and how to implement this fucntionality:

Every time I use logger.e for error level, I would like the logger to send this information in crashlytics so I can get report about it.
Right now I don't get any information about logger.e when app is in production env and in clients devices.

I can see console output only when I develop

@Desync-o-tron
Copy link

I too am interested see documentation added for how I can send my logs to sentry.io

@Desync-o-tron
Copy link

It looks like we can use the LogOutput class to send events to a network target.

@haroonkhan9426
Copy link

haroonkhan9426 commented Jun 19, 2022

Here it’s also mentioned in the official docs that you can log events anywhere e.g file, firebase or logcat etc.
I hope it helps.
Screenshot 2022-06-19 at 2 52 03 PM

@ayberkcal
Copy link

I've using different approach use Logger with Firebase Crashlytics. Maybe this example give an idea for you.
Extend Default Logger (mm_logger.dart)
I only override error method because I just want to log errors in Firebase Crashlytics you can override another methods if you want.

class MMLogger extends Logger {
  /// Create a new instance of MMLogger.
  ///
  /// You can provide a custom [printer], [filter] and [output]. Otherwise the
  /// defaults: [PrettyPrinter], [DevelopmentFilter] and [ConsoleOutput] will be
  /// used.
  MMLogger({
    LogFilter? filter,
    LogPrinter? printer,
    LogOutput? output,
    Level? level,
  }) : super(filter: filter, printer: printer, output: output, level: level);

  @override
  void e(dynamic message, [dynamic error, StackTrace? stackTrace]) {
    super.e(message, error, stackTrace);
    FirebaseCrashlytics.instance.recordError(error, stackTrace,
        // reason: 'a fatal error',
        // Pass in 'fatal' argument
        fatal: true);
  }
}

Create instance from MMLogger instead of Default Logger (main.dart):

final logger = MMLogger(
  filter: null, // Use the default LogFilter (-> only log in debug mode)
  printer: PrettyPrinter(), // Use the PrettyPrinter to format and print log
  output: null, // Use the default LogOutput (-> send everything to console)
);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants