1. 解析 adb logcat 的帮助信息
首先运行cmd命令行,然后输入chcp 65001命令,切换为UTF-8编码。接着在命令行中输入 adb logcat --help 命令, 就可以显示该命令的帮助信息;
octopus@octopus:~$ adb 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. (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', 'system', 'radio'
or 'events'. Multiple -b parameters are allowed and the
results are interleaved. The default is -b main -b system.
-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"
adb logcat 命令格式 : adb logcat [选项] [过滤项], 其中 选项 和 过滤项 在 中括号 [] 中, 说明这是可选的;
(1) 选项解析
选项解析 :
-- "-s"选项 : 设置输出日志的标签, 只显示该标签的日志;
-- "-f"选项 : 将日志输出到文件, 默认输出到标准输出流中, -f 参数执行不成功;
-- "-r"选项 : 按照每千字节输出日志, 需要 -f 参数, 不过这个命令没有执行成功;
-- "-n"选项 : 设置日志输出的最大数目, 需要 -r 参数, 这个执行 感觉 跟 adb logcat 效果一样;
-- "-v"选项 : 设置日志的输出格式, 注意只能设置一项;
-- "-c"选项 : 清空所有的日志缓存信息;
-- "-d"选项 : 将缓存的日志输出到屏幕上, 并且不会阻塞;
-- "-t"选项 : 输出最近的几行日志, 输出完退出, 不阻塞;
-- "-g"选项 : 查看日志缓冲区信息;
-- "-b"选项 : 加载一个日志缓冲区, 默认是 main, 下面详解;
-- "-B"选项 : 以二进制形式输出日志;
.
输出指定标签内容 :
-- "-s"选项 : 设置默认的过滤器, 如 我们想要输出 "System.out" 标签的信息, 就可以使用 adb logcat -s System.out 命令;

本文链接:https://it72.com:4443/12388.htm