Table of Contents
logcat -d -v time -s trace:I *:W
1 基本命令
1.1 adb logcat
打印日志信息,并且是阻塞的,有新的日志信息会立刻在屏幕上打印出来
1.2 adb logcat -d
打印日志信息,不同在于,它会退回到命令行模式,不阻塞
1.3 adb logcat -g
显示日志缓冲区的大小和位置
1.4 adb logcat -c
清除以前的所有日志
1.5 adb logcat -v [brief,process,tag,thread,raw,time,threadtime,long]
这行命令是设置日志的显示格式
1.5.1 adb logcat -v time
同时显示log生成时间
1.6 adb logcat -s [TAG]:[Level]
根据tag和等级过滤
2 过滤
adb logcat tag:priority
优先级从低到高为
V | — Verbose (lowest priority) |
D | — Debug |
I | — Info |
W | — Warning |
E | — Error |
F | — Fatal |
S | — Silent (highest priority, on which nothing is ever printed) |
多个过滤以空格分隔,不加-s的话每个过滤都只作用于当前tag,例如:
adb logcat ActivityManager:I MyApp:D *:S
3 日志输出格式
adb logcat -v time
brief | — Display priority/tag and PID of originating process (the default format). 默认的log类型 |
process | — Display PID only. 进程id前移 |
tag | — Display the priority/tag only. 不包含进程id |
thread | — Display process:thread and priority/tag only. 包含线程号 |
raw | — Display the raw log message, with no other metadata fields. 只包含log中的内容 |
time | — Display the date, invocation time, priority/tag, and PID of the originating process. 包含此log被调用的日期时间 |
long | — Display all metadata fields and separate messages with a blank lines. 包含所有信息 |
4 可用日志缓冲区
adb logcat -b radio
radio | — 查看缓冲区的相关的信息. |
events | — 查看和事件相关的的缓冲区. |
main | — 查看主要的日志缓冲区 |