如何使用 Android adb logcat 按 TAG 名称排除某些消息? [英] How to exclude certain messages by TAG name using Android adb logcat?

查看:51
本文介绍了如何使用 Android adb logcat 按 TAG 名称排除某些消息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Logcat 允许过滤日志,但它的工作原理是这样的:您定义过滤器,而 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?

推荐答案

如果你使用的是 adb logcat 你可以通过 grep 管道并使用它的反向匹配:来自 grep 手册页:

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反转匹配的意义,选择不匹配的行.

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

例如:

$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)"

这将检查给定中的任何一个发生,然后 grep 不会列出它们.

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

这篇关于如何使用 Android adb logcat 按 TAG 名称排除某些消息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆