Search code examples
androidandroid-log

Retrieving calls to Log? e.g. Log.w() Log.e() Log.i()


For an app I'm developing, I want to ease troubleshooting, both while it's in development and when it's released. I want to be able to retrieve calls to Log for when the app is being run without the phone connected in USB debugging, so it can be retrieved and sent to me. For example, when the app crashes, or when Log.e(...) is called, the log history (Calls to Log.i(), Log.w()) can be sent to a server, or the user can send it to me manually.

How can/should this be done?

Also, should the technique vary depending on if the app is in development vs release? (I know from the android Log docs that Log.v(...) should not be compiled into release versions - is there a better way than commenting out all those calls?)

It might make sense to extend Log or roll my own, but the devil is in the details.


Solution

  • For retrieving crash logs there is a library ACRA. Acra will send crash reports to your server. Alternately, google play also has a crashes & ANR's tab in the developer console where user's submitted crash reports are stored. Google play console's crash report is very easy to use and provides additional information of the number of same crashes and the version of the app in which the crash happened.