android - 使用 adb shell 禁用优先级为 ERROR 的垃圾邮件日志

标签 android shell android-logcat

我一直在使用一个闭源库,它的开发人员决定记录每个操作是明智的,无论多么微不足道,优先级为 ERROR。许多这些操作发生在连续循环中。我可以在 logcat 中过滤输出,但是相关消息消失的速度比我在 DDMS 的 logcat 查看器中读取它们的速度还要快。

到目前为止,我已经尝试了以下方法:

stop
setprop <tag> 7 //it looks like setprop expects the pri level as a string, so this won't
start           //work

stop
setprop <tag> INFO //I think this allows for INFO pri logs and above, so that doesn't
start              //help

logcat <tag>:S //should suppress all logs from the given tag, but has no effect on
               //logs in logcat and starts cloning logcat output to the shell for some
               //reason
logcat *:S //tried just to see if it would work -- it printed the beginning of new
           //empty log session to the shell and then never returned control of the shell.
           //logcat output in Eclipse was unaffected

作为 root,但这些都没有抑制 ERROR 垃圾邮件。我是否需要指定在设备上运行的目标 VM,上面的命令应该应用于该设备还是它们是系统范围的?如果我确实需要指定一个 VM,我该怎么做?我发现唯一相关的官方文档是 this用于 logcat 过滤。是否有全面的 setprop 手册,最好来自 Google?

主要问题:有什么方法可以禁用/抑制所有带有给定标签的日志,即使优先级是 ERROR?

it can't be turned off... but it does break easily

最佳答案

一种方法是过滤掉来自命令行的消息并将它们存储在错误文件中。 您可以尝试以下命令:

adb logcat :W | grep -v "^E" > error.log

.

*:W

过滤器表达式显示所有标签上优先级为“warning”及更高的日志消息

grep -v "^E"*

过滤掉所有错误信息。

> error.log

将所有这些消息保存在一个文件中。

希望这对您有所帮助。

关于android - 使用 adb shell 禁用优先级为 ERROR 的垃圾邮件日志,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26895211/

相关文章:

java - Android Activity生命周期: when to save the Logcat into a file?

android - 实际 Android 设备未找到 adb 设备

java - 奇怪的目录没有提供任何解释

Android 仪表板图标大小

android - Android 11创建CSV文件返回错误 "java.io.FileNotFoundException: EPERM (Operation not permitted)"

linux - 通过HTTP代理的SSH隧道

linux - 从 csv 文件中删除非 ascii 特殊字符

android - SSL 连接是否适用于 AsyncHttpclient?

java - 如何处理 AsyncTask 失败

linux - 无法解压文件?