0

We have a use case where we want to remotely collect system logs of Android 7 devices (and probably Android 8 in future). These are not consumer devices and we are using them for our business purpose only.

On searching this problem all links are pointing to using adb logcat over USB. However, it is not possible for us since we don't have physical access to our devices. I tried running logcat as a process and I was able to fetch system logs. However, this kind of sounds like a hack. Is there any API or any official way to gather system logs programatically from Android App.

Example of running logcat process is here: Read logcat programmatically within application

Thanks

c2tarun
  • 776
  • 2
  • 9
  • 27
  • 1
    "I tried running logcat as a process and I was able to fetch system logs" -- that only works on Android 4.0.3 and older, from `adb shell`, or on rooted devices or similar unusual scenarios. "Is there any API or any official way to gather system logs programatically from Android App." -- no, for privacy and security reasons. Apps have a tendency to log all sorts of unfortunate things, which is why in-app log access was restricted starting with Android 4.1. – CommonsWare Dec 29 '17 at 17:45
  • Thanks for replying, I just wanted to confirm when you say Android 4.0.3 and older you mean later right? Because I tried this on my Android 7 device and Android 8 emulator (both are not rooted). Running `logcat` process method works on both. – c2tarun Dec 29 '17 at 18:00
  • No, I mean older. [Ordinary apps cannot hold the `READ_LOGS` permission as of Android 4.1](https://commonsware.com/blog/2012/07/12/read-logs-regression.html). While the command will run without that permission, it should only return log messages from your own app, and a handful of system messages. Most system messages, and messages from other apps, should not be in the output. If it is, that's a significant security flaw in your particular devices. – CommonsWare Dec 29 '17 at 18:01
  • Got it. I didn't notice that I am getting logs from only my app. Thanks for your help. :) – c2tarun Dec 29 '17 at 18:29

0 Answers0