日志存放位置:/dev/log

shell@xxx:/ $ ls /dev/log -l
crw-rw-rw- root log , -- : events
crw-rw-rw- root log , -- : main
crw-rw-rw- root log , -- : radio
crw-rw-rw- root log , -- : system

提示信息的格式:等级/标签 (pid):日志内容

E/NetworkController(  934): onReceive ETHERNET_STATE_CHANGED_ACTION

等级

V:Verbose
D: Debug
I: Info
W: Warn
E: Error
F: Fatal
S: Silent (supress all output)

标签:用来区分不同的调试信息,必须唯一。

logcat命令

shell@xxx:/ $ logcat --help
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. ( if unspecified). Requires -f
-n <count> Sets max number of rotated logs to <count>, default
-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"

用法:logcat   [选项]   [过滤规则]

-s:过滤,输出指定标签的信息

// 打印标签为"NetworkController"的所有日志
shell@xxx:/ $ logcat -s "NetworkController"
// 打印标签为"NetworkController",并且等级为 D 的日志
shell@xxx:/ $ logcat -s "NetworkController:D"

-f <filename>:日志输出到文件,默认到标准输出

shell@xxx:/ # logcat -f /data/local/tmp/log.txt

-v <format>:设置日志的打印格式,format只能取下面中的一个,brief / process / tag / thread / raw / time / threadtime / long

brief:显示等级、标签、pid和消息,是默认格式

process:显示等级、pid和消息

tag:显示等级、标签和消息

thread:显示等级、pid、线程和消息

raw:只显示消息

time:显示时间、等级、标签、pid和消息

threadtime:显示时间、等级、pid、线程和消息

long:显示时间、等级、pid、线程和消息,但消息内容在下一行显示,而且每条日志之间空一行。

// 日志添加时间(最常用)
shell@xxx:/ # logcat -v time

-c:清空日志信息

shell@xxx:/ # logcat -c

-d:打印日志并退出,不阻塞

shell@xxx:/ # logcat -d

-t <count>:打印最近count行日志,不阻塞

shell@xxx:/ # logcat -t 

-g:查看缓冲区大小并退出

shell@xxx:/ # logcat -g
main: ring buffer is 256Kb (7Kb consumed), max entry is 5120b, max payload is 4076b
system: ring buffer is 256Kb (3Kb consumed), max entry is 5120b, max payload is 4076b
crash: ring buffer is 256Kb (0b consumed), max entry is 5120b, max payload is 4076b

-b <buffer>:查看指定缓冲区,允许多个 -b 参数,并且打印是交错的

<buffer>可取:main / system / radio / event / crash / all,默认为 -b main -b system -b carsh

shell@xxx:/ # logcat -b main -b radio

-B:以二进制形式输出日志

shell@xxx:/ # logcat -B

-S:输出统计数据

shell@xxx:/ # logcat -S

-G <size>:设置日志环缓冲区的大小,可以使用K或M

shell@xxx:/ # logcat -G 256Kb

 |grep:过滤日志中的字符串,与-s过滤标签不一样

shell@xxx:/ # logcat -b main -b system -b radio -v time |grep SETUP_DATA_CALL

>:输出日志到文件(windows系统)

shell@xxx:/ #  logcat -b radio -v time > d:/log.txt

最新文章

  1. Does Lamda expression return value?
  2. C++拼接字符串
  3. Oracle添加数据报文字与格式字符串不匹配错误
  4. Leetcode 290 Word Pattern STL
  5. 雅虎工程师提供的CSS初始化代码
  6. Linux_常用命令_02
  7. MSDN知识库_c#关键字_static
  8. jQuery实现列表自动滚动
  9. I2C的读写操作实验
  10. !!!易控INSPEC组态软件开发小结——-一次工程文件损坏和处理经过
  11. 【Oracle】-【体系结构】-【DBWR】-DBWR进程相关理解
  12. JVM GC(整理)
  13. mysql/mariadb主从复制
  14. 终于懂得Perl句柄是什么意思了
  15. zabbix系列 ~ mongo监控相关
  16. xenserver挂载新硬盘
  17. MYSQL和oracle 大小写问题
  18. 如何使用阿里巴巴iconfont矢量图片
  19. 关于 Dropout 防止过拟合的问题
  20. iOS开发-通过正则表达式判断字符串是否为纯阿拉伯数字

热门文章

  1. web前端 —— 移动端知识的一些总结
  2. configParse模块
  3. JavaScript数字和字符串转换示例
  4. Mysql 表锁定的问题
  5. ios入门第一天
  6. The capacitive screen technology - tadpole
  7. Spring报错: org.springframework.beans.factory.support.BeanDefinitionValidationException: Couldn&#39;t find an init method named &#39;init&#39; on bean with name &#39;car&#39;(待解答)
  8. 浅谈title属性与alt属性
  9. jq的.off解绑事件
  10. 使用pipework将Docker容器配置到本地网络环境中