13

我的应用程序使用的外部库之一在其 logcat 标记中有空格:

Log.d("Some External Library", "Debug Message");

如何在 logcat 命令中编写 filter-spec 来处理空格?eclipse 中的 Logcat 能够过滤它,但我更喜欢命令行。

我尝试了以下方法,但它们不起作用:

adb logcat -s "Some External Library"
adb logcat -s Some\ External\ Library
adb logcat -s Some External Library
4

1 回答 1

7

所以我的建议是使用管道。写:

adb logcat | grep 'Some External Library'

也许其他人有另一个想法。

如果您只需要调试消息写入adb logcat '*:D' | grep 'Some External Library'更多可能的标签,请写入adb logcat --help

问题在于,您不能在adb shell环境中使用此解决方案,因为那里的文件系统是只读的。但是这个解决方案应该或多或少地给你你想要的结果。

adb logcat -s 'Some External Library' 之类的命令或logcat -s '"Some External Library":D' 不起作用。

于 2011-02-11T16:53:32.173 回答