Android命令行工具logcat详细用法

Android命令行工具logcat详细用法
http://blog.csdn.net/lizhiguo0532/article/details/6553887
http://developer.android.com/tools/help/adb.html
1:命令格式:
logcat [option] ... [filter-spec] ...//用空格/" ".隔开
[option]:
  -s               默认设置过滤器,如指定'*:s'. 
  -f <filename>    输出到文件,默认情况是标准输出.
  -r [<kbytes>]    循环log的字节数(默认为16),需要-f.
  -n <count>       设置循环log的最大数目,默认是4
  -v <format>      设置log的打印格式,  <format> 是下面的一种: brief process tag thread raw time threadtime long.
  -c               清除所有log并退出.
  -d               得到所有log并退出 (不阻塞).
  -g               得到环形缓冲区的大小并退出. 
  -b <buffer>      请求不同的环形缓冲区('main' (默认), 'radio', 'events').
  -B               输出log到二进制中.
[filter-spec]:
过滤器语句按照下面的格式描述:tag:priority.tag 表示是标签,priority是表示标签log的最低等级
优先级有下列集中,是按照从低到高顺利排列的:
V - Verbose (lowest priority) 
D - Debug 
I - Info 
W - Warning 
E - Error 
F - Fatal 
S - Silent (highest priority, on which nothing is ever printed)

2:常用输入格式:
(1):控制”日志输出格式:
 logcat [-v <format>]
其中format选项如下:
brief         - Display priority/tag and PID of originating process (the default format). 
process     - Display PID only. 
tag         - Display the priority/tag only. 
thread     - Display process:thread and priority/tag only. 
raw        - Display the raw log message, with no other metadata fields. 
time         - Display the date, invocation time, priority/tag, and PID of the originating process. 
long        - Display all metadata fields and separate messages with a blank lines.
例子:
brief         -- P/tag (876): message  (默认格式)
process     -- (876): message
tag         -- P/tag: message
thread     -- P/tag( 876:0x37c) message
raw         -- message
time         -- 09-08 05:40:26.729 P/tag ( 876): message
threadtime     -- 09-08 05:40:26.729 876 892 P/tag : message
long         -- [ 09-08 05:40:26.729 876:0x37c P/tag ] message

(2):查看”可用日志缓冲区:
logcat [-b <buffer>]
其中buffer选项如下: 
radio     - 查看缓冲区的相关的信息. 
events - 查看和事件相关的的缓冲区. 
main     - 查看主要的日志缓冲区

4:编程代码:
 java code:
import java.util.Slog;
ex: Slog.i/Slog.e/Slog.d/Slog.w(TAG, “….”)
c/cpp code:
system/core/include/cutils/klog.h
#define KLOG_DEFAULT_LEVEL  3  /* messages <= this level are logged */
ERROR: 3, WARNING: 4, NOTICE: 5, INFO: 6, DEBUG: 7
system/core/include/cutils/log.h
    ex: ALOGD/ALOGI/ALOGE (“….”)


 

猜你喜欢

转载自blog.csdn.net/u011961033/article/details/83044557