Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Filter output in logcat by tagname

I'm trying to filter logcat output from a real device (not an emulator) by tag name but I get all the messages which is quite a spam. I just want to read messages from browser which should be something like "browser:" or "webkit:" , but it doesn't work... Here it is what I get:

actual output

like image 210
munch Avatar asked May 30 '11 08:05

munch


5 Answers

use this:

adb logcat -s "TAGNAME"
like image 114
sat Avatar answered Sep 30 '22 01:09

sat


In case someone stumbles in on this like I did, you can filter on multiple tags by adding a comma in between, like so:

adb logcat -s "browser","webkit"
like image 44
aarislarsen Avatar answered Sep 30 '22 00:09

aarislarsen


Another option is setting the log levels for specific tags:

adb logcat SensorService:S PowerManagerService:S NfcService:S power:I Sensors:E

If you just want to set the log levels for some tags you can do it on a tag by tag basis.

like image 43
mkobit Avatar answered Sep 29 '22 23:09

mkobit


Do not depend on ADB shell, just treat it (the adb logcat) a normal linux output and then pip it:

$ adb shell logcat | grep YouTag
# just like: 
$ ps -ef | grep your_proc 
like image 21
Siwei Avatar answered Sep 30 '22 01:09

Siwei


Here is how I create a tag:

private static final String TAG = SomeActivity.class.getSimpleName();
 Log.d(TAG, "some description");

You could use getCannonicalName

Here I have following TAG filters:

  • any (*) View - VERBOSE
  • any (*) Activity - VERBOSE
  • any tag starting with Xyz(*) - ERROR
  • System.out - SILENT (since I am using Log in my own code)

Here what I type in terminal:

$  adb logcat *View:V *Activity:V Xyz*:E System.out:S
like image 20
user3566154 Avatar answered Sep 30 '22 00:09

user3566154