0

I've seen plenty of ways of getting system logs in Android with logcat and the like, but not so much about app logs (except for the usual USB + adb solution).

My B2B Android app produces useful logging created with Log.i calls. Whilst in Studio these are very useful for debugging, it would also be useful to get these from customer's installs when things go wrong, i.e. from a release build out in the wild. Customers are generally not techies so getting logs via adb isn't really an option.

Is there a way within the app code itself to grab all the log contents?

Perhaps the SDK provides a way to do this?

I could then send that to my server or by email. I'm thinking it'll be useful for my customers to just hit a button so I can get an instantaneous snapshot of what is happening in the app.

Thanks in advance

UPDATE

There doesn't seem to be a way to do this, aside from writing to a file and sending that file. Which I guess is a good a solution as any.

Two other interesting ones that have come up are:

Manish Patel
  • 4,411
  • 4
  • 25
  • 48
  • 1
    There is no documented and supported means of doing this. You will find undocumented and unsupported solutions that run the `logcat` command on the device. You may be better served logging this information to some file that you control. – CommonsWare Apr 07 '17 at 15:45
  • 1
    i am not sure but did you try crashlytics? or firebase? – Mohammed Atif Apr 07 '17 at 16:46
  • @MohammedAtif both crashlytics and firebase give you crash reports, but they only give stack traces plus some other info. I need to have logs in the non-crashing case too. Instabug looks good, but it's not free – Manish Patel Apr 10 '17 at 08:13
  • @MohammedAtif actually there is event logging with firebase, so that's a possibility - https://firebase.google.com/docs/analytics/android/events – Manish Patel Apr 10 '17 at 08:21

1 Answers1

0

we can write write logs to file using java.util.logging.Logger API.

How to write logs in text file when using java.util.logging.Logger

Check out here for writting crash log to a file

Community
  • 1
  • 1
Rissmon Suresh
  • 13,173
  • 5
  • 29
  • 38