Android Production Logging Best Practice [closed]

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


Solution 1:

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.

Solution 2:

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.

Solution 3:

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 ;)