如何发送 Crashlytics 日志

How to send Crashlytics log

我在我的应用程序中使用 Crashlytics(现在称为 Fabric)。

当应用程序崩溃时它运行良好。我可以在仪表板上找到问题。

我正在尝试使用日志记录。类似于:

Crashlytics.log(Log.WARN,MYTAG,"Error message");

我无法在仪表板中发送此日志。我刚刚尝试添加如下内容:

Crashlytics.logException(new RuntimeException("Fake exception"));

但它不发送日志。

Crashlytics 可以发送日志吗?

您正在正确发送日志。但是看看官方文档是怎么说的Logging Caught Exceptions

All logged exceptions will appear as "non-fatal" issues in the Crashlytics dashboard.

To reduce your users' network traffic, Crashlytics batches logged exceptions together and sends them the next time the app launches. If you don't see logged exceptions in your Crashlytics web dashboard, try restarting your app!

Android中,使用

发送自定义崩溃
Crashlytics.logException(new RuntimeException("Fake exception"));

然后重新启动您的应用程序

Crashlytics 中,select 非致命因素

在较新版本的 Crashlytics 上,您需要使用这些函数:

FirebaseCrashlytics.getInstance().log("Your message goes here")
FirebaseCrashlytics.getInstance().recordException(RuntimeException("Your message goes here"))

编辑:
正如@Peter 在评论中提到的,单独使用 log 是行不通的,您必须使用 recordException 函数将您的日志消息与异常

捆绑在一起