常常抓一份日志不知道怎么分析。
1 日志级别(priority)
• V —— Verbose(最低,输出得最多)
• D —— Debug
• I —— Info
• W —— Warning
• E —— Error
• F —— Fatal
• S —— Silent(最高,啥也不输出)
按某级别过滤日志则会将该级别及以上的日志输出。
adb logcat *:W 会将 Warning、Error、Fatal 和 Silent 日志输出。
打日志的时候经常会把缓存的日志也打出来,需要清空日志 :adb logcat -c
2 如何抓日志

adb logcat -v 选项指定日志输出格式
Brief — 显示优先级/标记和原始进程的PID (默认格式)
process— 仅显示进程PIDtag — 仅显示优先级/标记
tag—标签
raw— 显示原始的日志信息,没有其他的元数据字段
long —显示所有的元数据字段并且用空行分隔消息内容
time— 显示日期,调用时间,优先级/标记,PID
threadtime—线程
保存日志并打印日志:adb logcat -v time tee 路径/xxx.log
保存日志:adb logcat -v time >>XXX.log
3 如何看日志
1:关键字
Process [package name]
Force finishing
Force stopping
Killing
died
crashed
2:exception和error
常见有: IllegalArgumentException,RuntimeException,OutOfMemoryError,NullPointerException,ArrayIndexOfBoundException,NotFoundException,IOException,SocketTimeoutException,NoSuchMethodError等等

3:native 和java
signal
现象2:anr
A 界面操作按钮的点击等待响应时间超过5秒
B HandleMessage回调函数执行超过10秒,BroadcasterReciver里的onRecive()方法处理超过10秒
adb shell bugreport > anrlog.txt
网友评论