Detailed explanation of adb logcat command under DOS for android development
Reference URL: https://blog.csdn.net/joshua_love/article/details/52785729
adb logcat -v time > filename.txt Save the log log in a txt file under dos.
adb logcat --help can display the help letter of the command.
adb logcat command format : adb logcat [options] [filter items], where options and filter items are in brackets [], indicating that this is optional;
(1) Option analysis
Option parsing :
-- "-s" option : set the label of the output log, only show the log of this label;
-- "-f" option : output the log to a file, the default output is to the standard output stream, the -f parameter is unsuccessful;
-- "-r" option : output the log per kilobyte, the -f parameter is required, but this command was not executed successfully;
-- "-n" option : set the maximum number of log output, requires the -r parameter, this execution feels the same as adb logcat;
-- "-v" option : set the output format of the log, note that only one item can be set;
-- "-c" option : clear all log cache information;
-- "-d" option : output the cached log to the screen without blocking;
-- "-t" option : output the last few lines of log, exit after output, without blocking;
-- "-g" option : View log buffer information;
-- "-b" option : load a log buffer, the default is main, detailed below;
-- "-B" option : output log in binary form;
Output the content of the specified label :
Output log information to a file :
-- "-f" option : This option is followed by the input log file, use the adb logcat -f /sdcard/log.txt command, note that this log file is output to the mobile phone, you need to specify an appropriate path.
Specify the log output format of logcat :
-- "-v"选项 : 使用adb logcat -v time 命令, 可以啥看日志的输出时间;
使用adb logcat -v threadtime 命令, 可以啥看日志的输出时间和线程信息;
-- "brief"格式 : 这是默认的日志格式" 优先级 / 标签 (进程ID) : 日志信息 ", 使用adb logcat -v prief 命令;
logcat 工具在做android开发的过程中肯定是必不可少的,这里介绍几个我认为比较方便的logcat命令
1. adb logcat;
这个最简化的一个打log的命令,不过默认打出的log信息太少,个人很少用
2. adb logcat -v time;
增加加了打印时间信息
3. adb logcat -v threadtime;这个用的最多,不仅打印了时间而且还打印了PID 和 TID,在看log的时候可以通过PID 和 TID 进一步的过滤,比较方便,TID对于调试多线程的ap很方便
4. adb logcat -v threadtime -b radio;有的时候需要看radio的log,可以用这个了。
5. adb logcat -v threadtime | grep "keyword" ;对于只是想看一些关键调试信息的时候,用grep命令实时的查看结果就比较方便了
6. adb logcat -v threadtime TAG1:v TAG2:v ... *:s ;如果有多个TAG 标签,keyword不统一,不方便用grep,那么用各自的TAG标签就比较好一些,同时还可以根据log级别来过滤。