1

I need to get a longer log history from my Android app running on the Android mobile device.

Even though my app itself does not create a lot of logs (issued via Log.d, Log.w etc), I find that all the logs roll over - apparently caused by all the logs created by Android itself, plus triggered by other apps. At best I am able to get may be an hour or so worth of logs right now.

I have maximized the log buffer size on the device (16 MB). I tried to convert all my debug logs to warnings (Log.d to Log.w) (note: this may have helped some).

I am trying to get to a day's or so worth of history - without tethering the device to a computer all the time.

Any ideas?

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
Venu G.
  • 427
  • 1
  • 5
  • 10
  • Stop logging to Logcat and use some logging solution that logs to files. – CommonsWare Feb 24 '19 at 18:05
  • Anything you recommend? I would be concerned with performance impact of any solution that write to flash. (I think logCat writes only to RAM, but I could be mistaken) – Venu G. Feb 24 '19 at 18:43
  • 1
    "Anything you recommend?" -- there is [a category of logging-related libraries in the Android Arsenal](https://android-arsenal.com/tag/57?sort=created). "I would be concerned with performance impact of any solution that write to flash." -- then log less. Or look for logging libraries with good buffering capability. – CommonsWare Feb 24 '19 at 18:46
  • >> there is a category of logging-related libraries in the Android Arsenal. ---- Thanks, will check these out. – Venu G. Feb 24 '19 at 18:48

1 Answers1

0

I solved the problem by redirecting the logs from my app to a file in flash by spawning logcat from the app (when the app starts). See

How to redirect my log output from logcat to the SD-Card on an android device?

I used the --pid option to logcat to filter logs issued by my app's own process.

Make sure to get WRITE_EXTERNAL_STORAGE permission (AndroidManifest.xml as well as runtime).

Venu G.
  • 427
  • 1
  • 5
  • 10