Abby Abby - 7 months ago 311
Android Question

adb logcat filter by package name

I'm using

adb logcat
in the
directory. I'd like to filter out the log messages by package name, so I can see just the log messages that come from my app. I've gotten as far as using

adb logcat *:E

which only displays the messages on the error level. Then I tried to filter out things by tags (so if there is no other way to filter things out by app/package name, I thought I'd just put a name in the tag to filter those), but running something like

adb logcat TAG:E

doesn't seem to filter out anything. I've had a look at the Android Studio user guide, but that didn't get me any further, either.

I'm using Android Studio, and I'd like to see the log of my app after the app crashed when I'm really using it and not just debugging in Android Studio.

Thanks in advance for any help or tips.


You can filter adb logcat output by process ID by using the --pid=<pid> option.

To get the process ID for your app, you can run adb shell ps | FINDSTR <app name> (for Windows) or adb shell ps | grep <app name> (for *nix and OSX) while the app is still running.

Since you are trying to get logcat output after the app has crashed, the ps command won't work. You can generally filter logcat output by running adb logcat | FINDSTR <search term> (for Windows) or adb logcat | grep <search term> (for *nix and OSX).

This way, you can still assign meaningful tags to your debug messages and further filter on them.

Hope this helps!