Android Studio Logcat V2 使用指南(适配 2024 年版本)


✅ Android Studio Logcat V2 使用指南(适配 2024 年版本)

Logcat V2 是 Android Studio Giraffe(海豚)版本后的新日志系统,使用统一的搜索框进行日志过滤,支持灵活的语法组合和正则表达式。


📌 一、日志级别说明(level:

级别 说明 用法示例
Verbose 显示所有日志(最详细) level:V
Debug 显示调试信息 level:D
Info 显示一般信息 level:I
Warn 显示警告信息 level:W
Error 显示错误信息 level:E
Assert 显示断言信息 level:A

📌 二、过滤日志的常用语法

语法 作用 示例
tag:xxx 仅显示特定 tag 的日志 tag:MyActivity
-tag:xxx 排除特定 tag 的日志 -tag:BufferQueueProducer
`tag~:xxx yyy` 显示多个 tag(支持正则)
`-tag~:xxx yyy` 排除多个 tag(正则)
package:包名 显示特定应用的日志 package:com.xx.xx
text:xxx 日志内容中包含关键字 text:"update status"
level:X 设置日志级别(X 见上表) level:D

📌 三、常见使用组合示例

✅ 只看当前 App 的日志(默认通常已勾选)
bash 复制代码
package:com.xx.xx
✅ 排除系统底层 tag
bash 复制代码
-tag:BufferQueueProducer -tag:BufferQueueConsumer -tag:Choreographer
✅ 过滤多个 tag(正则写法)
bash 复制代码
tag~:GroupSliderLayer|PeopleGroupAdapter
✅ 排除多个 tag(正则写法)
bash 复制代码
-tag~:BufferQueueProducer|gralloc4|SurfaceControl
✅ 限制输出等级,只看 error 并指定 tag
bash 复制代码
level:E tag:GroupSliderLayer tag:PeoplePageViewModel

📌 四、小技巧与注意事项

  • 搜索历史会自动保存:你输入过的过滤条件,会在搜索框中保留历史记录,便于下次快速切换。

  • 过滤条件实时生效:不需要点击"应用"按钮,输入后立即过滤。

  • 组合灵活,可拼写类似 SQL 的条件表达式 :比如:

    bash 复制代码
    package:com.xx.xxlevel:D -tag~:BufferQueueProducer|gralloc4 text:refresh

📌 五、推荐过滤语句模版(开发调试常用)

bash 复制代码
package:com.xx.xxlevel:D -tag~:BufferQueueProducer|BufferQueueConsumer|Choreographer|SurfaceControl

这个过滤器可以帮助你专注于自己项目的日志,而不被系统底层输出干扰。


相关推荐
码农阿豪7 小时前
我把 OpenClaw 装进旧安卓手机后,又折腾了 3 天:飞书、ADB、SSH 全部打通
android·智能手机·飞书
蓝桉柒78 小时前
下载idea,用idea输入一个程序
java·ide·intellij-idea
有什么事8 小时前
把安卓搬上云端:云手机系统改造与内核优化拆解
android·智能手机
方白羽9 小时前
性能分析:Android Studio Profiler
android·性能优化·app
没文化的阿浩9 小时前
【MySQL】用户管理
android·mysql·adb
FlightYe10 小时前
音视频修炼之基础理论(五):AAC格式与解析
android·linux·c++·音视频·aac
法欧特斯卡雷特11 小时前
Kotlin 2.4.20 现已发布,新特性多不多?
android·开源·全栈
摇滚侠11 小时前
《SpringBoot 3:入门与应用实战》第 12 章 JDBC 与事务 使用 JdbcTemplate 阅读笔记 31
android·spring boot·笔记
Zeaon12 小时前
别再手写筛选栏了:一个可组合的 Flutter 选择组件(5 入口 × 7 委托)
android·flutter
Michaelwubo12 小时前
mysql8 主从 HA切换
android·adb