开发者

Android Production Logging Best Practice [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel th开发者_Go百科at this question can be improved and possibly reopened, visit the help center for guidance. Closed 10 years ago.

What are the best practices for logging in Android apps in production mode, keeping in mind the following requirements :

  1. Ability to upload logs for debugging

  2. Ability to clean up logs or set rollovers

Thanks


Our preference is to automatically upload only exceptions. For client logging we prefer to selectively set a flag or have a special debug version that we give to clients with problems.

Exception catching can be done with Thread. setDefaultUncaughtExceptionHandler(). There are some caveats with this (mainly you need to exit() the app after done with exception handling). See: http://groups.google.com/group/android-developers/browse_thread/thread/c32e8c6120bed5c5/54c28b745c0fca80

For log collection see android-log-collector. No need to use the whole package, see the source and copy-paste.


If you'd like to get the crash reports ACRA can be a good solution.ACRA is a library enabling Android Application to automatically post their crash reports to a GoogleDoc form.


To make post more complete.. Google embedded Crash report service in newer version of Android. For older versions, where that's not supported yet several services are available. among already mentioned I would recommend these two:

  • ACRA (Crash reports - several options for reporting, chosen by developer or/and user)
  • HockeyApp (Testing/Crash reports web platform with support library. Trial but paid version is worth of it if u r serious developer. support for iOS as well)

However.. Most of these libraries will make your app a bit "heavier", but more important thing is that internet permission is required for use of them. In case your app doesn't need internet for some other reason, it might be suspicious to the user why you need internet if no feature require it.

Final word: Try to use as much as possible service Google already provided for Android, over 3rd party libraries.

Cheers ;)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜