adb logcat教程
1.速查
$adb logcat -g //打印和缓冲区使用情况
$adb logcat -c main //清除main缓存区
$adb logcat -v threadtime -f /data/camera.log | grep -Ei "camera | daemon"
- -v threadtime 输出格式 ,默认是 brief
- -f /data/camera.log 保存到文件
- grep -Ei "camera | daemon" 是过滤,-i是忽略大小写,E是指定多个过滤字符串,logcat的自代过滤器(tag:优先级)不好用!
2.先要知道的第一件事
android把log输出到不同的缓冲区中,常见的几个log缓冲区:
| 缓冲区 | 描述 |
| radio | 输出通信系统的log |
| system | 输出系统组件的log |
| crash | 崩溃日志 |
| events | 输出event模块的log |
| main |
所有java层的log,以及不属于上面3层的log |
| all |
全部 |
3.先要知道的第二件事
- 有两个logcat : adb logcat 与 adb shell logcat 命令不同,使用场景不同。
- logcat有很多参数:adb logcat --help 可查看。
4.参数详解
第1个参数:打印各日志缓冲区的大小并退出
$adb logcag -g
结果如下:
main: ring buffer is 256Kb (235Kb consumed), max entry is 5120b, max payload is 4076b
system: ring buffer is 256Kb (238Kb consumed), max entry is 5120b, max payload is 4076b
crash: ring buffer is 256Kb (242Kb consumed), max entry is 5120b, max payload is 4076b
第2个参数:打印某个缓冲区日志
$adb logcat -b system
默认是 -b main -b system -b crash.
第3个参数:设置log的输出格式
$adb logcat -v threadtime
threadtime是输出格式,常见输出格式:
|
格式 |
说明 |
| brief | 显示优先级/标记和过程的PID发出的消息(默认格式) |
| process | 只显示PID |
| tag | 只显示优先级/标记 |
| raw | 显示原始的日志消息,没有其他元数据字段 |
| time | 调用显示日期、时间、优先级/标签和过程的PID发出消息 |
| thread | 过滤线程 |
| threadtime | 调用显示日期、时间、优先级、标签以及PID TID线程发出的消息 |
| long | 显示所有元数据字段与空白行和单独的消息 |

第4个参数:设置过滤器[ tag名:优先级 ] ,默认是[*:I]
$adb logcat ActivityManager:I YourApp:D *:S
这个命令指定了3个过滤器:
- ActivityManager:I
- YourApp:D
- *:S
其中ActivityManager和YourApp是tag,I 、D 、S是优先级。优先级表如下:从低到高
| V | Verbose(最低优先级) |
| D | Debug |
| I | Info |
| W | Warning |
| E | Error |
| F | Fatal |
| S | Silent |
再来一个例子:
$adb logcat *:E
第5个参数:输出到文件(注意文件保存在设备上)
$adb logcat -v threadtime -f /data/camera.log
5.详解,有些参数可以合并一起,最好分开,如 -v xxx -f xxx
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)
-t '<time>' print most recent lines since specified time (implies -d)
-T <count> print only the most recent <count> lines (does not imply -d)
-T '<time>' print most recent lines since specified time (not imply -d)
count is pure numerical, time is 'MM-DD hh:mm:ss.mmm'
-g get the size of the log's ring buffer and exit
-b <buffer> Request alternate ring buffer, 'main', 'system', 'radio',
'events', 'crash' or 'all'. Multiple -b parameters are
allowed and results are interleaved. The default is
-b main -b system -b crash.
-B output the log in binary.
-S output statistics.
-G <size> set size of log ring buffer, may suffix with K or M.
-p print prune white and ~black list. Service is specified as
UID, UID/PID or /PID. Weighed for quicker pruning if prefix
with ~, otherwise weighed for longevity if unadorned. All
other pruning activity is oldest first. Special case ~!
represents an automatic quicker pruning for the noisiest
UID as determined by the current statistics.
-P '<list> ...' set prune white and ~black list, using same format as
printed above. Must be quoted. 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"
adb logcat教程的更多相关文章
- Android ADB命令教程二——ADB命令详解
Android ADB命令教程二——ADB命令详解 转载▼ 原文链接:http://www.tbk.ren/article/249.html 我们使用 adb -h 来看看,adb命令里面 ...
- adb logcat 基本用法
入门android ,至少需要了解 adb 吧,那么打 log 也是必不可少的了. 下面简单介绍一下 adb logcat 基本用法: Usage: logcat [options] [filters ...
- 如何用adb logcat保存日志
//将log 保存到当前目录下 adb logcat -v time >a.log //log过滤 adb logcat | grep MyAppName //清除log adb logcat ...
- adb logcat 命令
转自:http://blog.csdn.net/tumuzhuanjia/article/details/39555445 1. 解析 adb logcat 的帮助信息 在命令行中输入 adb log ...
- dos保存adb logcat读取的Android信息
/***************************************************************************** * dos保存adb logcat读取的A ...
- 如何过滤 adb logcat 输出
对原作者表示感谢,转自博客:http://www.otechu.me/zh/2011/12/filtering-adb-logcat-output/ 本文介绍如何在 shell 命令行中过滤 adb ...
- adb logcat调试中常用的命令介绍
Android日志系统提供了记录和查看系统调试信息的功能.日志都是从各种软件和一些系统的缓冲区中记录下来的,缓冲区可以通过 logcat 命 令来查看和使用. adb logcat 命令格式 : ad ...
- adb logcat 查看日志
使用 logcat 命令 查看和跟踪系统日志缓冲区的命令logcat的一般用法是: [adb] logcat [<option>] ... [<filter-spec>] .. ...
- adb logcat命令查看并过滤android输出log
cmd命令行中使用adb logcat命令查看android系统和应用的log,dos窗口按ctrl+c中断输出log记录. logcat日志中的优先级/tag标记: android输出的每一条日志都 ...
随机推荐
- 关于 SWT 的UI线程和非UI线程
要理解UI线程,先要了解一下“消息循环”这个概念.链接是百度百科上的条目,简单地说,操作系统把用户界面上的每个操作都转化成为对应的消息,加入消息队列.然后把消息转发给对应的应用程序(一般来说,就是活动 ...
- Hadoop 文件压缩
一.目的 a. 减小磁盘占用 b. 加速网络IO 二.几个常用压缩算法 是否可切分:是指压缩后的文件能否支持在任意位置往后读取数据. 各种压缩格式特点: 压缩算法都需要权衡 空间/时间 :压缩率越高, ...
- Easy smart REST with kbmMW
使用新版kbmMW开发的 smart service,也可以轻松的发布为通过REST来调用的功能. 一个 kbmMW smart service象下面这样实现,就可以使用REST来访问: ty ...
- 初探linux子系统集之led子系统(三)【转】
本文转载自:http://blog.csdn.net/eastmoon502136/article/details/37822837 世界杯结束了,德国战车夺得了大力神杯,阿根廷最终还是失败了.也许3 ...
- jconsole工具检测堆内存变化的使用
jconsole将Java写的程序检测. 从Java 5开始 引入了 JConsole.JConsole 是一个内置 Java 性能分析器,可以从命令行或在 GUI shell 中运行.您可以轻松地使 ...
- 一步一步学Silverlight 2系列(23):Silverlight与HTML混合之无窗口模式
概述 Silverlight 2 Beta 1版本发布了,无论从Runtime还是Tools都给我们带来了很多的惊喜,如支持框架语言Visual Basic, Visual C#, IronRuby, ...
- holiday题解
题目描述如下: 经过几个月辛勤的工作,FJ 决定让奶牛放假.假期可以在 1…N 天内任意选择一段(需要连续),每一天都有一个享受指数 W.但是奶牛的要求非常苛刻,假期不能短于 P 天,否则奶牛不能得到 ...
- LNMP+Zabbix的安装与部署
LNMP+Zabbix的安装与部署 一.Zabbix简介 1.zabbix是一个基于WEB界面的,并提供分布式系统监视以及网络监视功能的企业级的开源解决方案. zabbix能监视各种网络参数,保证服务 ...
- python-day-9- 进程-异步IO\
本节内容 进程 Gevent协程 Select\Poll\Epoll异步IO与事件驱动 多进程multiprocessing multiprocessing is a package that sup ...
- windows下安装RabbitMQ消息服务器 + 读写队列
RabbitMQ是什么 ? RabbitMQ是一个在AMQP基础上完整的,可复用的企业消息系统.他遵循Mozilla Public License开源协议. 1:安装RabbitMQ需要先安装Erla ...