how can I send log information from my Android app

2019-02-17 03:55发布

I'm developing an Android app that is currently in the Play Store. I've been getting reports of a crash on certain devices that I can't reproduce, and the Play Store's built in crash diagnostics don't contain enough information. What I really need is the Logcat information from these devices, but it seems that Android 4.1 and above don't allow the use of those "Log Collector" apps that used to be so popular for this purpose due to security concerns. Is there a library that I can add to my app that will allow it to log to a remote server on demand? I know enough about this crash that I could put a call to some mythical sendLogcatNow() function in the appropriate spot in the code, if I had such a function. Since the information I seek is not actually part of the crash (the crash occurs later), normal crash reporting tools such as Crashlytics don't seem like they will do what I need, but perhaps they have this feature and it's just not prominent in the documentation. Thanks!

4条回答
孤傲高冷的网名
2楼-- · 2019-02-17 04:10

There are few version for crash reporting..

  1. Hockey App
  2. Acra
  3. BugSense
  4. Android Remote stack trace
  5. Since your app can always read logs for it's own process, you can also implement something of your own.

Out of all these, I personally prefer Acra. as it is most efficient and give many options to app developers.

查看更多
欢心
3楼-- · 2019-02-17 04:11

I would look into using a third party production crash system, there are a few out there. I am currently using Crashlytics. This specific service allows you to log and set key value pairs during the running of the application that get packaged with the crash report. These services also offer greater insight into the device type, OS and a variety of other device details.

With this set up I have then created a log function that will submit to the Crashlytics service as well as logging it to log cat.

查看更多
虎瘦雄心在
4楼-- · 2019-02-17 04:18

I'm using ACRA for logging crashes from my app but based on their documentation,

  • you can add your own variables content or debug traces to the reports
  • you can send error reports even if the application doesn't crash

Which seems to be doing what you want.

https://github.com/ACRA/acra

You will need to run your own ACRA server (simple enough to run) and get your app to send the crash logs to your server. Everything is detailed on their website.

查看更多
再贱就再见
5楼-- · 2019-02-17 04:20

You can also use Google Analytics or Flurry. But note that Google Analytics doesn't log stack traces and Flurry doesn't support real-time log reports on server.

查看更多
登录 后发表回答