androidfilteradblogcat

How to exclude certain messages by TAG name using Android adb logcat?


Logcat allows filtering logs but it works like that: You define filters and logcat only displays messages which matches filters. But is there a way to display all logs EXCEPT some TAGs defined by filters?


Solution

  • If you are using adb logcat you could pipe it through grep and use it's inverted matching: From the grep manpage:

    v, --invert-match Invert the sense of matching, to select non-matching lines.

    For example:

    $adb logcat | grep --invert-match 'notshownmatchpattern' 
    

    You can extend this by using regular expressions.

    Here is an example of such an expression:

    "/^(?:emails|tags|addresses)"
    

    This one would check for either of the given to occur, grep would then not list them.