【发布时间】:2012-10-22 02:02:21
【问题描述】:
默认的 Eclipse LogCat 窗口包含大量来自 VM 的控制台垃圾邮件等。如何删除这些消息?似乎现在唯一的过滤器是过滤 for 表达式,而不是 过滤 垃圾邮件。
【问题讨论】:
默认的 Eclipse LogCat 窗口包含大量来自 VM 的控制台垃圾邮件等。如何删除这些消息?似乎现在唯一的过滤器是过滤 for 表达式,而不是 过滤 垃圾邮件。
【问题讨论】:
此外,如果您想过滤您不感兴趣的日志消息,则可以使用 logcat 的“filter_spec”的静默选项 (S)。
例如,如果您想过滤 Dalvik VM 的日志消息,例如
D/dalvikvm(28039):GC_CONCURRENT 释放 473K,7% 释放 9503K/10180K,暂停 2ms+3ms,共 22ms
那么你可以使用
adb logcat dalvikvm:S
【讨论】:
根据定义,这是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
【讨论】:
adb logcat MyAppTag:V '*:W',它显示了我的应用程序中的所有内容,以及其他任何内容的警告。
一种选择是改用命令行。
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}'
这将突出显示您的应用程序的名称,删除通常包含垃圾邮件的消息,并打印它不知道的任何内容。
【讨论】: