logcat命令使用方法和查看android系统日志缓冲区内容的方法

2019-12-10 20:09:33王振洲

where <tag> is a log component tag (or * for all) and priority is:
tag 是 eclipse 中 logcat 图形界面中 Tag 的内容(或者有 * 表示全部),它之后的冒号(:)后面跟优先级:
    日志类型标识符(优先级由低到高排列):
    1. V — Verbose 详细的 <- 最低优先权
    2. D — Debug   调试
    3. I — Info    消息
    4. W — Warn    警告
    5. E — Error   错误
    6. F — Fatal   致命的
    7. S — Silent  无声的 <- 最高优先权

'*' means '*:d' and <tag> by itself means <tag>:v
* 意味着 *:d 且 单孤地 tag 意味着 tag:V

If not specified on the commandline, filterspec is set from ANDROID_LOG_TAGS.
如果在命令行上没有详细说明,过滤规格即是 ANDROID_LOG_TAGS 结果集。

If no filterspec is found, filter defaults to '*:I'
如果没有过滤说明,过滤规格默认为 *:I

If not specified with -v, format is set from ANDROID_PRINTF_LOG or defaults to "brief"
如果没有 -v 指定格式,将是 ANDROID_PRINTF_LOG 或 brief 格式集。

1) 只输出指定 标签 和 类型 的日志
   格式:
   adb logcat <日志标签>:<日志类型标识符> <日志标签>:<日志类型标识符> ... *:S
   注:1. 可以写多个 <日志标签>:<日志类型标识符> 之间用空格分隔;
     2. 最后必须是 *:S ,表示其它的都不要显示出来
   例如:
   $ adb logcat dalvikvm:D Checkin:W *:S

   注:adb logcat Checkin *:S =等同于=> adb logcat Checkin:V *:S
   注:以上命令均没加 -v 来指出日志格式,即默认为: ANDROID_PRINTF_LOG 或 brief 格式集。

2) 输出指定 标签 和 类型 的带有格式的日志
注:以下测试日志内容为:test log format,
  即 eclipse 中的 logcat 图形界面里的 Text 中的内容!

1. brief      - 日志类型/日志标签(进程ID): 日志内容
   例如:$ adb logcat -v brief Checkin *:S
      I/Checkin(24713): test log format
      
2. process    - 日志类型(进程ID) 日志内容 (日志标签)