Logging using Crashlytics

此生再无相见时 提交于 2019-12-03 23:56:21

The log message will be saved with the exception. So the Crashlytics.log("1"); wont do anything without an exception.

You should fire like that:

Crashlytics.log(Log.ERROR, "YourTAG", "YourMessage");
Crashlytics.logException(new Throwable("YourERROR"));

I'd like to add a note to other passersby that the extra logs are only viewable on a per session basis. In a given issue, click the View All Sessions button and you'll see additional info for keys and logs. All logs held by fabric are shown here, so you can log numerous times before the exception. This took a surprisingly long time for me to realize.

As others have noticed and as documented, Crashlytics may not send the log reports until a throwable is logged via logException. Keep that in mind if the logs aren't appearing on that screen.

I am using the Crashlytics log system and I can see more that one log. In fact I can see all the logs that I've added to the app before the crash point.

My guess is that your app has a crash before your "message 2" log line.

It seems that Crashlytics is writing the log messages asynchronously. So you will always have a race condition when using Crashlytics.log().

Depending on what you are doing a short (and ugly) sleep before crashing may solve this issue:

Crashlytics.log("1");
Crashlytics.log("2");
try {
    Thread.sleep(1000);
} catch (InterruptedException e) {
    // NOP: Ignored!
}
throw new RuntimeException("Failed directly after logging.");

Or you can use custom keys instead:

Crashlytics.setString("SOME_IMPORTANT_VALUE", "1");

According to the Crashlytics docs:

To make sure that sending crash reports has the smallest impact on your user’s devices, Crashlytics logs have a maximum size of 64 KB. When a log exceeds 64 KB, the earliest logged values will be dropped in order to maintain this threshold.

Your first message will be dropped if the second message plus the first message exceed 64KB.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!