我观察到,当我使用Logcat Eclipse ADT for Android时,我也从许多其他应用程序获得消息。是否有一种方法来过滤这个,只显示来自我自己的应用程序的消息。


当前回答

Windows命令提示符方式:adb logcat -d | findstr <package>.使用实例

*这是jj_首先提到的,但我花了很长时间才在评论中找到它…

其他回答

我写了一个shell脚本,通过包名过滤logcat,我认为这比使用更可靠

ps | grep com.example.package | cut -c10-15

它使用/proc/$pid/cmdline找到实际的pid,然后在logcat上执行grep

https://gist.github.com/kevinxucs/7340e1b1dd2239a2b04a

在intelliJ中(可能在eclipse中也有),你可以通过文本webview过滤logcat输出,所以它基本上打印phonegap生成的所有内容

把这个放到applog.sh

#!/bin/sh
PACKAGE=$1
APPPID=`adb -d shell ps | grep "${PACKAGE}" | cut -c10-15 | sed -e 's/ //g'`
adb -d logcat -v long \
 | tr -d '\r' | sed -e '/^\[.*\]/ {N; s/\n/ /}' | grep -v '^$' \
 | grep " ${APPPID}:"

然后: applog.sh com.example.my.package

使用-s !

你应该使用你自己的标签,看看: http://developer.android.com/reference/android/util/Log.html 喜欢的。 日志。d(“AlexeysActivity”,“你想要记录什么”); 然后当你想读取日志时使用> adb logcat -s AlexeysActivity 过滤掉所有不使用相同标签的内容。

Windows命令提示符方式:adb logcat -d | findstr <package>.使用实例

*这是jj_首先提到的,但我花了很长时间才在评论中找到它…