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

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

Posted by: admin March 10, 2020 Leave a comment


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.

How to&Answers:

Package names are guaranteed to be unique so you can use the Log function with the tag as your package name and then filter by package name:

NOTE: As of Build Tools 21.0.3 this will no longer work as TAGS are restricted to 23 characters or less.

Log.<log level>("<your package name>", "message");

adb -d logcat <your package name>:<log level> *:S

-d denotes an actual device and -e denotes an emulator. If there’s more than 1 emulator running you can use -s emulator-<emulator number> (eg, -s emulator-5558)

Example: adb -d logcat com.example.example:I *:S

Or if you are using System.out.print to send messages to the log you can use adb -d logcat System.out:I *:S to show only calls to System.out.

You can find all the log levels and more info here: https://developer.android.com/studio/command-line/logcat.html


EDIT: Looks like I jumped the gun a little and just realized you were asking about logcat in Eclipse. What I posted above is for using logcat through adb from the command line. I’m not sure if the same filters transfer over into Eclipse.


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.


On Windows you can do:

adb logcat | findstr com.example.package


Add filter

Add filter

Specify names

enter image description here

Choose your filter.

enter image description here


Since Android 7.0, logcat has –pid filter option, and pidof command is available, replace com.example.app to your package name.
(ubuntu terminal / Since Android 7.0)

adb logcat --pid=`adb shell pidof -s com.example.app`


adb logcat --pid=$(adb shell pidof -s com.example.app)

For more info about pidof command:


For me this works in mac Terminal
Got to the folder where you have adb then type below command in terminal

./adb logcat MyTAG:V AndroidRuntime:E *:S

Here it will filter all logs of MyTAG and AndroidRuntime


Update May 17

It’s been a few years, and thing have changed. And Eclipse is no longer officially supported. So here’s two more up-to-date approaches:

1. Android Studio

enter image description here
In the Android monitor toolbox, you can filter logcat per debuggable process. Normally, when you develop an application it is a debuggable process. Every once in a while I am having issues with this, and a do the following:

  1. Tools -> Android -> Enable ADB Integration.

    If it was already enabled, then toggle it off, and then back on

  2. Unplug and replug your mobile device.

There are also options to filter via regex and the debug level

2. logcat-color

This is a nice python wrapper on top of adb logcat if you want to use a terminal based solution. The good thing about it is that you can save multiple configurations and simply reuse them. Filtering by tags is quite reliable. You can also filter by package to see logs of one or more apps only, but you start logcat-color right before launching your app.

Old Answer:

It seems that I can’t comment to previous answers, so I will post a new one.
This is a comment to Tom Mulcahy‘s answer, that shows how the command should change so as to work on most devices, since adb shell ps PID column is variable.

NOTE: The command below works for the cases where you have connected many devices. So device id is needed. Otherwise, you can simply omit the brackets ‘[‘, ‘]’

1. To find out the column of pid, type:

adb [-s DEVICE_ID] shell ps | head -n 1

Now memorise the column number for the PID. Numbering starts from 1.

2. Then type the following:

adb [-s DEVICE_ID] logcat | grep $(adb [-s DEVICE_ID] shell ps \
| grep "com.example" | awk -F" " ' {print $PUT_COLUMN_HERE}')

Simply put the column you memorised in PUT_COLUMN_HERE, e.g. $5


Each time you re-run your application, you have to re-run the 2nd command, because the application gets a new PID from the OS.


This has been working for me in git bash:

$ pid=$(adb shell ps | grep <package name> | cut -c11-15) ; adb logcat | grep $pid


put this to applog.sh

APPPID=`adb -d shell ps | grep "${PACKAGE}" | cut -c10-15 | sed -e 's/ //g'`
adb -d logcat -v long \
 | tr -d '\r' | sed -e '/^\[.*\]/ {N; s/\n/ /}' | grep -v '^$' \
 | grep " ${APPPID}:"

applog.sh com.example.my.package


This works for me with USB debugging:

  1. Connect the device and use:

    adb shell

  2. Simple use the logcat:

    logcat | grep com.youapp.packagename


If you are using Android Studio you can select the process from which you want to receive logcats.
Here is the screenshot.

enter image description here


I wrote a shell script for filtering logcat by package name, which I think is more reliable than using

ps | grep com.example.package | cut -c10-15

It uses /proc/$pid/cmdline to find out the actual pid, then do a grep on logcat



ADT v15 for Eclipse let you specify an application name (which is actually the package value in your androidmanifest.xml).

I love being able to filter by app, but the new logcat has a bug with the autoscroll. When you scroll up a little to look at previous logs, it automatically scrolls back to the bottom in a couple seconds. It seems scrolling 1/2 way up the log does keep it from jumping back to the bottom, but that’s often useless.

EDIT: I tried specifying an app filter from the command-line — but no luck. If someone figures this out OR how to stop the autoscroll, please let me know.


Using Windows command prompt: adb logcat -d | findstr <package>.

*This was first mentioned by jj_, but it took me ages to find it in the comments…


Ubuntu : adb logcat -b all -v color –pid=`adb shell pidof -s com.packagename` With color and continous log of app


As a variant you can use third party script PID Cat by Jake Wharton. This script has two major advantages:

  • shows log entries for processes from a specific application package
  • color logcat

From documentation:

During application development you often want to only display log messages coming from your app. Unfortunately, because the process ID changes every time you deploy to the phone it becomes a challenge to grep for the right thing.

This script solves that problem by filtering by application package.

An output looks like
enter image description here


I’m not sure there’s a way to only see system messages regarding your app, but you can filter based on a string. If you’re doing a log within the program, you can just include a certain unique keyword, and filter based on that word.


Try: Window -> Preferences -> Android -> LogCat. Change field “Show logcat view if …” the value “VERBOSE”. It helped me.


If you are using Eclipse, press the green + sign in the logCat window below and put your package name (com.example.yourappname) in the by Application Name box. Also, choose any name comfortable to you in Filter Name box and click ok. You will see only messages related to your application when the filter you just added is chosen from the left pane in the logCat.


Give your log a name. I called mine “wawa”.

enter image description here

In Android Studio, go to Android-> Edit Filter Configurations

enter image description here

Then type in the name you gave the logs. In my case, it’s called “wawa”. Here are some examples of the types of filters you can do. You can filter by System.out, System.err, Logs, or package names:

enter image description here
enter image description here
enter image description here


This is probably the simplest solution.

On top of a solution from Tom Mulcahy, you can further simplify it like below:

alias logcat="adb logcat | grep `adb shell ps | egrep '\bcom.your.package.name\b' | cut -c10-15`"

Usage is easy as normal alias. Just type the command in your shell:


The alias setup makes it handy. And the regex makes it robust for multi-process apps, assuming you care about the main process only.

Of coz you can set more aliases for each process as you please. Or use hegazy’s solution. 🙂

In addition, if you want to set logging levels, it is

alias logcat-w="adb logcat *:W | grep `adb shell ps | egrep '\bcom.your.package.name\b' | cut -c10-15`"


On Windows 10, using Ionic, what worked great to me was combine ‘findstr’ with the “INFO:CONSOLE” generated by all App messages.
So, my command in command line is:

adb logcat | findstr INFO:CONSOLE


I tried to use Tom Mulcahy’s answer but unfortunately it was not working for applications with multiple processes so I edit it to fit my needs.

if [ "$#" -ne 1 ]; then echo "Illegal number of parameters"; exit 1; fi
echo "Lof for package name: $1"
PROCESSES=`adb shell ps | grep "$1" | cut -c10-15`
if [ $NUM_OF_PROCESSES -eq 0 ]; then echo "The application is not running!"; exit 1; fi
for process in $PROCESSES; do
        if [ $COUNTER -eq 1 ]; then GREP_TEXT="("; fi
        if [ $COUNTER -eq $NUM_OF_PROCESSES ]; then GREP_TEXT+=")"; else GREP_TEXT+="|"; fi
        let COUNTER=COUNTER+1 
        if [ $COUNTER -gt $NUM_OF_PROCESSES ]; then break; fi  
adb logcat | grep -E "$GREP_TEXT"


Use -s !

You should use your own tag, look at:


Log.d("AlexeysActivity","what you want to log");

And then when you want to read the log use>

adb logcat -s AlexeysActivity

That filters out everything that doesn’t use the same tag.



In addition to Tom Mulcahy‘s answer, if you want to filter by PID on Windows’ console, you can create a little batch file like that:


:: find the process id of our app (2nd token)
FOR /F "tokens=1-2" %%A IN ('adb shell ps ^| findstr com.example.my.package') DO SET PID=%%B

:: run logcat and filter the output by PID
adb logcat | findstr %PID%


This is obviously a question aimed at usage of Logcat from outside of the developer device, however if you want to display Logcat output on the device (programmatically), you just need this:

Runtime.getRuntime().exec("logcat " + android.os.Process.myPid() + " *:D");

The *:D at the end filters out every message below Debug log level but you can leave that out.

To direct the output to, say, a TextView, see for example here.


Now is possible to type tag:nameofthetag or app:nameoftheapp to filter without adding new filters to the saved filters bar


In intelliJ (and probably in eclipse also) you can filter the logcat output by text webview, so it prints basically everything phonegap is producing


Yet another variant of Gavriel’s applog.sh with support of several devices and applications with multiple processes:


APPIDS=`adb [email protected] shell ps | awk -v PKG="$PKG" '
    (NR == 1){appcolumn=2; for (i=1; i<=NF; i++) if ($i=="PID") {appcolumn=i}}
    index($0,PKG){print $(appcolumn)}' | paste -d \| -s`

echo "PID's: $APPIDS"
adb [email protected] logcat -v color | awk  "(\ ~ /$APPIDS/){print \
#!/bin/sh PKG=$1 shift APPIDS=`adb [email protected] shell ps | awk -v PKG="$PKG" ' (NR == 1){appcolumn=2; for (i=1; i<=NF; i++) if ($i=="PID") {appcolumn=i}} index($0,PKG){print $(appcolumn)}' | paste -d \| -s` echo "PID's: $APPIDS" adb [email protected] logcat -v color | awk "(\$3 ~ /$APPIDS/){print \$0}" 

Usage: applog.sh com.example.my.package [-s <specific device>]


In linux, this worked for me:

adb logcat | grep `adb shell ps | grep your.package | awk '{print $2}'`