Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Filter LogCat to get only the messages from My Application in Android?

I observed that when i use Logcat with Eclipse with ADT for Android, I get messages from many other applications as well. Is there a way to filter this and show only messages from my own application only.

like image 710
Vinod Avatar asked Jul 28 '11 04:07

Vinod


People also ask

What is regex in Logcat?

regexp,AndroidStudio,logcat. Logcat provides several default filter options (Verbose, Info, Debug etc) and a simple pattern match filter, but the regex filter is the most powerful option for customizing logcat output.

What is PID in Logcat?

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


1 Answers

Linux and OS X

Use ps/grep/cut to grab the PID, then grep for logcat entries with that PID. Here's the command I use:

adb logcat | grep -F "`adb shell ps | grep com.asanayoga.asanarebel  | tr -s [:space:] ' ' | cut -d' ' -f2`" 

(You could improve the regex further to avoid the theoretical problem of unrelated log lines containing the same number, but it's never been an issue for me)

This also works when matching multiple processes.

Windows

On Windows you can do:

adb logcat | findstr com.example.package 
like image 172
Tom Mulcahy Avatar answered Oct 19 '22 20:10

Tom Mulcahy