How can I filter Android logcat output by application? I need this because when I attach a device, I can't find the output I want due to spam from other processes.
-
Just adding a good reference which can help you... http://developer.android.com/guide/developing/debugging/debugging-log.html I hope this can help you in more detail – havexz Nov 02 '11 at 02:41
-
as from android studio ver 0.4.5 u will get messages from the app that is running only.`Log cat has a new option (on by default) which creates an application filter automatically such that only the launched application's output is shown` – dmSherazi Feb 16 '14 at 09:22
-
@CiroSantilli709大抓捕六四事件法轮功 That one's specific to Eclipse; this is about logcat itself. – James Moore May 02 '17 at 22:31
-
https://github.com/kashifrazzaqui/punt Try this tool out - it makes filtering much easier. – keios Mar 09 '21 at 11:23
27 Answers
Edit: The original is below. When one Android Studio didn't exist. But if you want to filter on your entire application I would use pidcat for terminal viewing or Android Studio. Using pidcat instead of logcat then the tags don't need to be the application. You can just call it with pidcat com.your.application
You should use your own tag, look at: http://developer.android.com/reference/android/util/Log.html
Like.
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.

- 8,085
- 3
- 30
- 38
-
47I thought Tags are used to identify which class/Application part is logging? In eclipse's logcat view it is possbile to filter by Application (for instance: de.myapplication.someapp) - so if eclipse's logcat can do that, there surely must be a way to do the same when using adb logcat? About the Tag's I mentioned: [Logging Conventions](http://developer.android.com/reference/android/util/Log.html) – AgentKnopf Mar 20 '12 at 07:35
-
You could use several different options using logcat and adb. That was just one example. If you want more take a look at: http://developer.android.com/guide/developing/tools/adb.html – David Olsson Mar 20 '12 at 08:10
-
13I think this link: http://developer.android.com/guide/developing/tools/logcat.html is more related to logcat commands. However it does (as far as I can see) not say how to filter the log by an application's (package-)name or process id. But eclipse does it, so I just wonder how ... – AgentKnopf Mar 20 '12 at 08:15
-
30You didn't answer the question. He wants to separate his application log data from everything else going on in his phone. – EGHDK Apr 06 '12 at 01:30
-
5I don't think you can filter by application with the command-line version of logcat. I suspect that the Eclipse logcat plugin is just dumping out all the logs and then doing its own filtering. – Edward Falk Aug 21 '12 at 20:00
-
1The question was specific about "by application", not "by tag" – Knuckles the Echidna Mar 31 '14 at 09:35
-
3This should not be the accepted answer, you *can* filter by application in both IDE's and (through grep) command line. – stevebot Jun 09 '14 at 22:34
-
26-1 because it's not an answer to the question. It asked to filter by application and not by tag. – Henrik Erlandsson Jun 18 '14 at 13:54
-
By the time of the writing android studio didnt exists. You are all welcome to edit the answer or put in your own answer. But the fact still remains, doing logging like that can filter by application. Geez, answer is 3 years old - stuff updates. – David Olsson Jun 20 '14 at 16:27
-
How do you grep for the application name? None of the adb logcat formats seem to output the application name. – Edward Falk Oct 03 '14 at 19:19
-
1I suppose filtering by tag does not show exceptions on application crash. So I'm also interested in filtering by application. My filtering by tag does not show the exceptions. – Stephane Mar 21 '15 at 12:25
-
2The CORRECT answer would be to gep by PID, e.g. programatically you'd "Runtime.getRuntime().exec("logcat -v threadtime -d|grep " + android.os.Process.myPid()" – raudi May 20 '15 at 13:06
-
1How can this be accepted answer? This **DOES NOT** filter by application. – Atul Aug 18 '16 at 04:45
-
@raudi You're free to put newlines in an entry, so anything that's just using grep on a pid isn't going to work either. – James Moore May 02 '17 at 22:33
-
PID changes every time you rerun the application which is not really filtering by application. – Vlad Dec 08 '17 at 23:15
According to http://developer.android.com/tools/debugging/debugging-log.html:
Here's an example of a filter expression that suppresses all log messages except those with the tag "ActivityManager", at priority "Info" or above, and all log messages with tag "MyApp", with priority "Debug" or above:
adb logcat ActivityManager:I MyApp:D *:S
The final element in the above expression, *:S, sets the priority level for all tags to "silent", thus ensuring only log messages with "View" and "MyApp" are displayed.
- V — Verbose (lowest priority)
- D — Debug
- I — Info
- W — Warning
- E — Error
- F — Fatal
- S — Silent (highest priority, on which nothing is ever printed)

- 625
- 6
- 5
-
9what if i want to have all the classes of a package? e.g., `com.example.android.*:D` ? it does not work, maybe it clash with the `*:S` As log tag i use the full classname, thus the package. Maybe a bad practice? – EsseTi Sep 22 '14 at 08:05
Hi I got the solution by using this :
You have to execute this command from terminal. I got the result,
adb logcat | grep `adb shell ps | grep com.package | cut -c10-15`

- 953
- 1
- 10
- 28
-
2Really nice, this simply works auto-magically, great. I use this with logcat-color to get it nicely colorised along with the timestamps too then command looks like this: logcat-color -v time *:v | grep `adb shell ps | grep com.alrimal | cut -c10-15` – Dragan Marjanović Jan 19 '15 at 10:10
-
7This is great except that you'll have to re-run the command every time your app restarts (it'll get a new PID). Also, you might replace `cut` with `awk` like this: `adb logcat | grep "$(adb shell ps | grep com.your.package | awk '{print $2}')"` – kristianlm Jul 09 '16 at 18:57
I am working on Android Studio, there is a nice option to get the message using package name. On the "Edit Filter Configuration" you can create a new filter by adding your package name on the "by package name".

- 1,587
- 2
- 20
- 29
-
5
-
yap, it worked for me and also for others. It should work if you filter the log using appropriate package name. – Shad Nov 18 '13 at 04:59
-
1This works on IntelliJ 13 too. It seems filtering by package wasn't an option in 12 or lower. – Tom Manterfield Jan 26 '14 at 21:08
-
12Anybody know *how* it works? None of the "adb logcat" formatting options includes the application name. – Edward Falk Oct 03 '14 at 19:17
If you could live with the fact that you log are coming from an extra terminal window, I could recommend pidcat (Take only the package name and tracks PID changes.)

- 61,720
- 15
- 75
- 100
-
1Could you explain how to use pidcat? I'm a total newbie to the terminal, python and adb in general though – Gerald Eersteling Mar 05 '14 at 11:13
-
I love how it actually works. I cannot get the built-in android log to display my entire applications logs... it's so useless. pid works. +1 – Andrew G Aug 08 '15 at 13:54
Suppose your application named MyApp contains the following components.
- MyActivity1
- MyActivity2
- MyActivity3
- MyService
In order to filter the logging output from your application MyApp using logcat you would type the following.
adb logcat MyActivity1:v MyActivity2:v MyActivity3:v MyService:v *:s
However this requires you to know the TAG names for all of the components in your application rather than filtering using the application name MyApp. See logcat for specifics.
One solution to allow filtering at the application level would be to add a prefix to each of your unique TAG's.
- MyAppActivity1
- MyAppActivity2
- MyAppActivity3
- MyAppService
Now a wild card filter on the logcat output can be performed using the TAG prefix.
adb logcat | grep MyApp
The result will be the output from the entire application.

- 2,361
- 18
- 8
-
4On a Windows system (or a system without `grep`), simply connect to the device using `adb shell`, then run the command: `shell@myDevice:/ $ logcat | grep MyApp` – CJBS Sep 16 '14 at 23:43
-
This doesn't work for log messages produced by system components or libraries running within your process. – Jules Jun 25 '17 at 14:51
put this to applog.sh
#!/bin/sh
PACKAGE=$1
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}:"
then:
applog.sh com.example.my.package

- 18,880
- 12
- 68
- 105
-
1Not perfect, in that it only provides the first line of multi-line output, but the best solution of those above. – Sep 11 '14 at 10:15
-
2Instead of that weird `cut` & `sed` combo, you can jsut use `awk '{print $2}'` :-) – kralyk Apr 17 '16 at 11:28
When we get some error from our application, Logcat will show session filter automatically. We can create session filter by self. Just add a new logcat filter, fill the filter name form. Then fill the by application name with your application package. (for example : my application is "Adukan" and the package is "com.adukan", so I fill by application name with application package "com.adukan")

- 328
- 3
- 8
If you use Eclipse you are able to filter by application just like it is possible with Android Studio as presented by shadmazumder.
Just go to logcat, click on Display Saved Filters view, then add new logcat filter. It will appear the following:
Then you add a name to the filter and, at by application name you specify the package of your application.

- 4,892
- 4
- 31
- 50

- 2,455
- 22
- 25
On my Windows 7 laptop, I use 'adb logcat | find "com.example.name"' to filter the system program related logcat output from the rest. The output from the logcat program is piped into the find command. Every line that contains 'com.example.name' is output to the window. The double quotes are part of the find command.
To include the output from my Log commands, I use the package name, here "com.example.name", as part of the first parameter in my Log commands like this:
Log.d("com.example.name activity1", "message");
Note: My Samsung Galaxy phone puts out a lot less program related output than the Level 17 emulator.

- 915
- 10
- 8
-
-
I use 'adb logcat | find "com.example.name"' The Best Ans here tHANKS – Stephen Ngethe Oct 25 '15 at 14:25
-
This doesn't work for log messages produced by system components or libraries running within your process, which don't have your application name as part of their tag. – Jules Jun 25 '17 at 14:52
I use to store it in a file:
int pid = android.os.Process.myPid();
File outputFile = new File(Environment.getExternalStorageDirectory() + "/logs/logcat.txt");
try {
String command = "logcat | grep " + pid + " > " + outputFile.getAbsolutePath();
Process p = Runtime.getRuntime().exec("su");
OutputStream os = p.getOutputStream();
os.write((command + "\n").getBytes("ASCII"));
} catch (IOException e) {
e.printStackTrace();
}

- 5,511
- 4
- 32
- 53
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:
logcat
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`"

- 516
- 4
- 12
-
-
character spacing seems to be unreliable - awk '{print $2}' works for me instead of cut. Thanks. – Bill McGonigle Apr 22 '19 at 21:23
On the left in the logcat view you have the "Saved Filters" windows. Here you can add a new logcat filter by Application Name (for example, com.your.package)

- 111
- 1
- 13
What I usually do is have a separate filter by PID which would be the equivalent of the current session. But of course it changes every time you run the application. Not good, but it's the only way the have all the info about the app regardless of the log tag.

- 16,865
- 6
- 62
- 72
Generally, I do this command "adb shell ps" in prompt (allows to see processes running) and it's possible to discover aplication's pid. With this pid in hands, go to Eclipse and write pid:XXXX (XXXX is the application pid) then logs output is filtered by this application.
Or, in a easier way... in logcat view on Eclipse, search for any word related with your desired application, discover the pid, and then do a filter by pid "pid:XXXX".

- 11
- 1
you can achieve this in Eclipse logcat by entering the following to the search field.
app:com.example.myapp
com.example.myapp is the application package name.

- 736
- 7
- 19
my .bash_profile function, it may be of any use
logcat() {
if [ -z "$1" ]
then
echo "Process Id argument missing."; return
fi
pidFilter="\b$1\b"
pid=$(adb shell ps | egrep $pidFilter | cut -c10-15)
if [ -z "$pid" ]
then
echo "Process $1 is not running."; return
fi
adb logcat | grep $pid
}
alias logcat-myapp="logcat com.sample.myapp"
Usage:
$ logcat-myapp
$ logcat com.android.something.app

- 379
- 3
- 6
In Android Studio in the Android Monitor window: 1. Select the application you want to filter 2. Select "Show only selected application"

- 1,055
- 12
- 12
Yes now you will get it automatically....
Update to AVD 14, where the logcat will automatic session filter
where it filter log in you specific app (package)

- 34,521
- 28
- 94
- 112
Use fully qualified class names for your log tags:
public class MyActivity extends Activity {
private static final String TAG = MyActivity.class.getName();
}
Then
Log.i(TAG, "hi");
Then use grep
adb logcat | grep com.myapp

- 2,966
- 1
- 21
- 23
-
This doesn't work for log messages produced by system components or libraries running within your process, which don't have your application name as part of their tag. – Jules Jun 25 '17 at 14:53
The Android Device Monitor application available under sdk/tools/monitor has a logcat option to filter 'by Application Name' where you enter the application package name.

- 464
- 5
- 6
On Linux/Un*X/Cygwin you can get list of all tags in project (with appended :V
after each) with this command (split because readability):
$ git grep 'String\s\+TAG\s*=\s*' | \
perl -ne 's/.*String\s+TAG\s*=\s*"?([^".]+).*;.*/$1:V/g && print ' | \
sort | xargs
AccelerometerListener:V ADNList:V Ashared:V AudioDialog:V BitmapUtils:V # ...
It covers tags defined both ways of defining tags:
private static final String TAG = "AudioDialog";
private static final String TAG = SipProfileDb.class.getSimpleName();
And then just use it for adb logcat.

- 4,523
- 3
- 33
- 44
I have found an app on the store which can show the name / process of a log. Since Android Studio just puts a (?) on the logs being generated by the other processes, I found it useful to know which process is generating this log. But still this app is missing the filter by the process name. You can find it here.

- 5,171
- 3
- 23
- 40
Add your application's package in "Filter Name" by clicking on "+" button on left top corner in logcat.
use first parameter as your application name. Log.d("your_Application_Name","message");
and in LogCat : create Filter ---> Filter Name & by Log Tag: is equal to 'your_Application_Name' it will create new tab for your application.

- 3,693
- 5
- 37
- 59
-
This doesn't work for log messages produced by system components or libraries running within your process, which don't have your application name as part of their tag. – Jules Jun 25 '17 at 14:53
to filter the logs on command line use the below script
adb logcat com.yourpackage:v

- 317
- 3
- 11
-
This doesn't work for log messages produced by system components or libraries running within your process, which don't have your application name as part of their tag. – Jules Jun 25 '17 at 14:54
The log cat output can be filtered to only display messages from your package by using these arguments.
adb com.your.package:I *:s
Edit - I spoke to soon.
adb com.your.package:v

- 5
- 2
-
4I don't think that would work unless your application happened to use "com.your.package" as the log tag. – Edward Falk Aug 21 '12 at 19:59
-
This doesn't work for log messages produced by system components or libraries running within your process, which don't have your application name as part of their tag. – Jules Jun 25 '17 at 14:55