Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

adb shell Logcat with Package Name

Is it possible to also display the Log's Package Name in each line?
Using

logcat -v long

leaves exactly the package name field (after PID) empty.
I want to filter the Logs from a specific application with different Tags, just wondering if it is possible.

like image 755
Felix Plaumann Avatar asked Sep 23 '15 09:09

Felix Plaumann


People also ask

What is PID in Logcat?

pid = process ID. uid = user ID of the application that owns that process.


2 Answers

logcat record does not have a "package name field". Therefore there is no standard/built-in way to filter by it.

Although since Android 7.0 you can use logcat --pid option combined with pidof -s command to filter output by binary/package name:

adb shell "logcat --pid=$(pidof -s <package_name>)"

Replace " with ' for Linux/MacOS

like image 182
Alex P. Avatar answered Sep 18 '22 14:09

Alex P.


This is my script. A little 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 colours, and a while loop to keep monitoring for that process when it gets restarted, but I think you'll get the point.

like image 41
Lucas Vidal Avatar answered Sep 20 '22 14:09

Lucas Vidal