android - 过滤 LogCat 以仅从 Android 中的“我的应用程序”中获取消息?

标签 android android-studio logcat

我观察到,当我将 Logcat 与 Eclipse 和 ADT for Android 一起使用时,我也会从许多其他应用程序中获取消息。有没有办法过滤这个并只显示来 self 自己的应用程序的消息。

最佳答案

Linux 和 OS X

使用 ps/grep/cut 获取 PID,然后使用 grep 获取具有该 PID 的 logcat 条目。这是我使用的命令:

adb logcat | grep -F "`adb shell ps | grep com.asanayoga.asanarebel  | tr -s [:space:] ' ' | cut -d' ' -f2`"

(您可以进一步改进正则表达式以避免包含相同数字的不相关日志行的理论问题,但这对我来说从来都不是问题)

这在匹配多个进程时也有效。

窗口

在 Windows 上你可以这样做:

adb logcat | findstr com.example.package

关于android - 过滤 LogCat 以仅从 Android 中的“我的应用程序”中获取消息?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6854127/

相关文章:

android - 定期连接到服务器并检查更新可用性的最佳方法是什么

android -/dev/log/main 未找到

android - 从硬件设备执行时如何查看代码错误

android - 如何从包名中获取 PID?

android - 将 android 项目迁移到 Gradle?

java - 查找字符串数组列表之间的共同点

在输入值之前按下运算符时,Java Android 计算器崩溃

android-studio - 插件太旧,请更新到最新版本

android-studio - 无法解析 com.android.support.espresso :espresso-core:2. 2.2

使用模拟器时 Android Studio 2.3.3 Logcat "Unable to connect to the editor...";该怎么办?