使用crashlytics记录数据时出现问题 [英] Trouble with logging my data with crashlytics

查看:205
本文介绍了使用crashlytics记录数据时出现问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Android应用程序中的Crashlytics获取包含一些服务数据的日志.但是我在仪表板中看不到我的日志. 我用了这个:

I'm trying to get logs with some service data with Crashlytics in my android application. But I don't see my logs in dashboard. I used this:

String myLog = getServiceData(); //myLog is not null and non-empty
CrashLytics.log(myLog);

和这个:

String myLog = getServiceData(); //myLog is not null and non-empty
CrashLytics.log(Log.Error, getString(R.string.app_name), myLog);

我试图在我的应用程序中生成异常并对其进行处理,但是没有结果:

I tried to generate exception in my application and handle it, but have no results:

try {
   int a = 0;
   a = 1/a;
}
catch (Exception e) {
   CrashLytics.log(myLog);
}

我还阅读了 Crashlytics日志未发送我需要在记录数据之前初始化crashlytics.我将Crashlytics.start(this)放在Activity的onStart()事件中,但没有再次在仪表板上看到我的日志.最后,我尝试在记录数据之前直接将Crashlitycs.start(this)放入,但仪表盘中仍然没有日志.

Also I read on Crashlytics log not sent I need to initialize crashlytics before log data. I put Crashlytics.start(this) in onStart() event of my Activity but didn't see my logs in dashboard again. At last I tried to put Crashlitycs.start(this) directly before logging my data, but still have no logs in dashboard.

请告诉我我做错了什么以及如何在Crashlytics仪表板中获取自定义日志?

Plase, tell me what I do wrong and how to get my custom logs in Crashlytics dashboard?

推荐答案

我也遇到类似的情况.经过一些试验,我能够推断出Crashlytics行为的规则.

I had a similar situation. With some experimenting, I was able to deduce the rules to Crashlytics' behavior.

我在这里分享我的经验,因此(希望)其他人不必经历我为弄清楚而进行的艰巨而耗时的过程.

I'm sharing my learnings here so (hopefully) others don't have to go through the arduous and time-consuming process that I did to figure it out.

当发生致命异常时,Crashlytics只会立即将崩溃报告上载到仪表板".换句话说,当您的应用崩溃时.除非并且直到崩溃报告被上传,否则仪表板中不会显示任何内容.

Crashlytics will only upload a crash report "to the dashboard" immediately if a fatal exception occurs. In other words, when your app crashes. And nothing shows in the dashboard unless and until a crash report is uploaded.

如果您使用CrashLytics.logException(e)记录了非致命异常,则崩溃报告将不会上载,直到下次重新启动您的应用程序为止.因此,在应用重启之前,您不会在Crashlytics仪表板中看到该异常.

If you log a non-fatal exception, using CrashLytics.logException(e), a crash report will not be uploaded till the next time your app is restarted. So you will not see the exception in the Crashlytics dashboard till an app restart.

您可以确定何时进行上传,因为您会在LogCat中看到以下消息:

You can tell when an upload occurs because you'll see this sort of message in LogCat:

07-17 19:30:41.477 18815-18906/com.foo.bar I/Crashlytics﹕ Crashlytics report upload complete: 55A9BA0C01D7-0001-462D-B8B4C49333333.cls

Crashlytics日志消息必须与致命或非致命异常相关联,以显示在仪表板中.

A Crashlytics log message must be associated with a fatal or non-fatal exception to show up in the dashboard.

此外,与异常无关无关的日志消息在应用程序重启后仍然存在.

Furthermore, log messages that aren't associated with an exception do not survive app restart.

因此,如果您执行一些操作,例如记录一些消息,然后重新启动应用程序,则应用程序将引发异常,或者使用Crashlytics.logException()记录非致命异常,则日志消息将丢失.它们不会显示在仪表板中.

So, if you do something like log a few messages, then restart the app, then the app throws an exception, or it logs a non-fatal exception using Crashlytics.logException(), the log messages will be lost. They will not show up in the dashboard.

如果要记录某些消息而没有致命异常,请使用一个或多个Crashlytics.log()语句,后跟Crashlytics.logException().

If you want to log some messages without a fatal exception, use one or more Crashlytics.log() statements followed by Crashlytics.logException().

要验证其是否有效,请运行代码,然后重新启动应用程序.在仪表板中,您应该看到与为非致命异常创建的问题关联的日志.在野外,您只需要相信您的用户可以定期重启应用即可.

To verify that it works, have the code run, then restart the app. In the dashboard, you should see the logs associated with the issue created for the non-fatal exception. In the wild, you'll just have to trust your users restart the app with some regularity.

在Fabric/Crashlytics仪表板上,您需要选择All Events或(如果您只想查看记录调用,请选择)Non-Fatals.

On the Fabric/Crashlytics dashboard, you'll need to select All Events or (if you want to see just your logging calls) Non-Fatals.

这篇关于使用crashlytics记录数据时出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆