This question is w.r.t getting the logs from the logcat (using command-line tool).

I want to fetch the logs of a particular app after the app has been run for a specific amount of time (say 15 seconds) without any user involvement. So, I used the logcat using the command adb shell logcat --pid ProcessIdOfApp and when I tried to run the same app two times (after the fresh installation and cleaned all the earlier logs) using adb shell logcat -c, then also for many apps, I am getting different logs. When I am saying different logs what I mean here is we are getting different tags.

I also tried rebooting the smartphone and then installed the apk on the device, but still I am getting different logs.

My curiousity is when the same code is being executed, the corresponding logs generation should also be same. Why it is coming different when the same app has been launched multiple times?

  • Is it like I am not filtering the logs properly for a given app? If yes, then what command I should use to filter the logs for a given app?

  • Since I am getting different tags when the same app has been launch multiple times, how to know which tags should be ignored?

  • Have you seen: Filter LogCat to get only the messages from My Application in Android? Not sure/you didn't explain how you were getting ProcessIdOfApp Although I would probably just get the full logcat and grep for the app package. You might want to explain what you are trying to achieve, but please note that programming related questions are off-topic. Jul 3, 2021 at 10:19
  • 1
    "we are getting different tags." without knowing the exact logs/tags, we can only guess, but tags are free-form input. Developers can provide ever-changing tags on their apps if they want (which I can't think of why, but it's just possible).
    – Andrew T.
    Jul 3, 2021 at 11:43


You must log in to answer this question.

Browse other questions tagged .