Local adb shell with package name

Can I also display the log package name on each line?
Using

logcat -v long

Leaves the packet name field exactly (after the PID) blank.
I want to filter logs from a specific application with different tags, just wondering if this is possible.

+6
source share
2 answers

logcat entry does not have a package name field. Therefore, there is no standard / built-in filtering method.

Although with Android 7.0 you can use the logcat --pid option in conjunction with the pidof -s command to filter the output by the name of the binary / package:

 adb shell logcat --pid=$(pidof -s <package_name>) 
+4
source

This is my script. A bit rusty but still working.

 PID=`adb shell ps | grep -i <your package name> | cut -c10-15`; adb logcat | grep $PID 

Actually I have a python script to add more colors, and a while loop to keep track of this process when it restarts, but I think you get the point.

+6
source

All Articles