Filter output in logcat by tagname

后端 未结 5 1367
没有蜡笔的小新
没有蜡笔的小新 2020-11-28 19:37

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 brow

相关标签:
5条回答
  • 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 
    
    0 讨论(0)
  • 2020-11-28 20:12

    use this:

    adb logcat -s "TAGNAME"
    
    0 讨论(0)
  • 2020-11-28 20:12

    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.

    0 讨论(0)
  • 2020-11-28 20:15

    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
    
    0 讨论(0)
  • 2020-11-28 20:16

    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"
    
    0 讨论(0)
提交回复
热议问题