Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 464
Imad Khalaf Avatar asked Oct 29 '10 08:10

Imad Khalaf


People also ask

What should be logging level in production?

Logging levels are usually considered to be in order of importance: turn on "unimportant" levels in development ( trace , debug and the like), but enable only the "most important" levels ( warning , error , etc.) in production, where resources like CPU time and disk space are precious.

What is verbose logging level?

The Verbose level logs a message for both the activity start and end, plus the values of the variables and arguments that are used. By default, the Verbose level includes: Execution Started log entry - generated every time a process is started. Execution Ended log entry - generated every time a process is finalized.


2 Answers

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.

like image 138
Peter Knego Avatar answered Sep 20 '22 07:09

Peter Knego


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.

like image 31
100rabh Avatar answered Sep 21 '22 07:09

100rabh