Android - 如何从Eclipse LogCat过滤控制台垃圾邮件?

时间:2012-10-22 02:02:22

标签: android eclipse logcat

默认的Eclipse LogCat窗口包含来自VM等的大量控制台垃圾邮件。如何删除这些邮件?现在似乎唯一的过滤器是过滤表示表达式,而不是过滤掉垃圾邮件。

3 个答案:

答案 0 :(得分:7)

此外,如果您想过滤您不感兴趣的日志消息,则可以使用logcat的“filter_spec”的静默选项(S)。

例如,如果您想过滤Dalvik VM的日志消息,如

  

D / dalvikvm(28039):GC_CONCURRENT释放473K,7%免费9503K / 10180K,暂停2ms + 3ms,总计22ms

然后你可以使用

adb logcat dalvikvm:S

答案 1 :(得分:2)

根据定义,LogCat来自Developer Page - LogCat

logcat

The Android logging system provides a mechanism for collecting and viewing system debug 
output. Logs from various applications and portions of the system are collected in a 
series of circular buffers, which then can be viewed and filtered by the logcat command. 
You can use logcat from an ADB shell to view the log messages.

好吧,你可以通过标签,进程ID,字符串或表达式来过滤所需的内容。 无论如何,如果您对Logcat不太熟悉,请先试用本指南 - Learn how to control Logcat output

答案 2 :(得分:0)

一种选择是使用命令行。

appname=YOUR_APP_NAME_OR_LOG_TAG
adb logcat | awk '/'$appname'/{gsub(/'$appname'/, "\x1b[95m'$appname'\x1b[0m"); print; next}; /(dalvikvm|com.google.android.apps|PhoneStatusBar|DeviceConfig)/{next}; {print}'

这将突出显示您的应用程序的名称,删除包含典型垃圾邮件的邮件,并打印它不知道的任何内容。

相关问题