1.通过adb logcat -h 查看具体详细如下:
$ adb logcat -hunknown option -- hUnrecognized Option
Usage: logcat [options] [filterspecs]
options include:
-s Set default filter to silent.
Like specifying filterspec '*:s'
-f <filename> Log to file. Default to stdout
-r [<kbytes>] Rotate log every kbytes. (16 if unspecified). Requires -f
-n <count> Sets max number of rotated logs to <count>, default 4
-v <format> Sets the log print format, where <format> is one of:
brief process tag thread raw time threadtime long
-c clear (flush) the entire log and exit
-d dump the log and then exit (don't block)
-t <count> print only the most recent <count> lines (implies -d)
-g get the size of the log's ring buffer and exit
-b <buffer> request alternate ring buffer
('main' (default), 'radio', 'events')
-B output the log in binary
filterspecs are a series of
<tag>[:priority]
where <tag> is a log component tag (or * for all) and priority is:
V Verbose
D Debug
I Info
W Warn
E Error
F Fatal
S Silent (supress all output)
'*' means '*:d' and <tag> by itself means <tag>:v
If not specified on the commandline, filterspec is set from ANDROID_LOG_TAGS.
If no filterspec is found, filter defaults to '*:I'
If not specified with -v, format is set from ANDROID_PRINTF_LOG
or defaults to "brief"
2.主要的用法:
a.针对性地过滤 具体格式: adb logcat -s tag:priority
priority 级别:V< D < I < W < E < F < S
例如:
$adb logcat -s videocamera:I 显示tag为videocamera 级别为I 或比I级别更高的log。
b.日志输出格式
具体的格式如下:
brief — Display priority/tag and PID of originating process (the default format).
process — Display PID only.
tag — Display the priority/tag only.
thread — Display process:thread and priority/tag only.
raw — Display the raw log message, with no other metadata fields.
time — Display the date, invocation time, priority/tag, and PID of the originating process.
long — Display all metadata fields and separate messages with a blank lines.
例如:
$adb logcat -v raw
c. 查看不同的log缓冲区
常用的log缓冲区有如下三种:
main - 设备运行时的主要log信息
radio - 无线电和电话相关的log信息
events -事件相关的log信息
具体命令格式:adb logcat -b <main | events | radio>
d. 如果PC上接有两个以上设备的时候,可以使用该命令来操作
$adb devices
1234567890ABCDEF deviceemulator-5554 device
$adb -s 1234567890ABCDEF logcat 查看设备1234567890ABCDEF的log。
3.状况信息log
包括如下:
1) adb shelll cat /proc/kmsg
获取kernel log,检索用printk生成的内核消息, 主要查看msm_kgsl字段
2)adb shell dmesg
dmesg 是用于查看开机信息,kernel 将开机信息存于ring buffer,dmesg是kernel的log,凡是跟kernel有关的,比如driver出了问题(相机,蓝牙,usb,启动,等等)开机信息亦保存在/var/log目次中,名称为dmesg的文件里。
3)adb shell dumpstate
包含手机当前的内存信息、cpu信息、logcat缓存,kernel缓存等等
4) adb shell dumpsys
是关于service的内容log,具体用法: 比如adb shell dumpsys meminfo system是查看system这个process的内存信息。
5) adb bugreport
里面包含有dmesg,dumpstate和dumpsys。