Logcat
Introduction to Logcat: logcat is a command line tool for android, which is used for log information to the program
Logcat command format:
[adb] logcat [<option>]…[<filter-spec>]…
Window use: adb logcat
In Shell mode: logcat
Logcat parameter description
-b <buffer> Load a log buffer that can be used for viewing, such as event and radio default is main
-c clear all logs in the buffer and exit (you can use -g to view the buffer after clear)
-d dump the buffer log to the screen and exit
-f <filename> output the log to the specified file <filename> defaults to stdout
-g print log buffer size and exit
-n<count> Set the maximum number of logs <count> The default value is 4, it needs to be used together with -r
-r<kbytes> Output log without <kbytes>, the default value is 16, it needs to be used together with the -f option
-s set filter (*:S)
-v <format> Set the output format for log messages. Default is ephemeral format, list of supported formats
Generally, if the log is output for a long time, it is recommended to use the three parameters –f –n –r in combination, so that when the log output of one file is full, it can be output in the other one immediately.
Formatted output of Logcat
Parameter Description
Log messages contain a metadata field, and in addition to the label and priority, you can modify the output to display the message in a specific metadata field format. To do this, use the -v option to specify a supported output format
brief Display priority/tag and PID of the process to send out messages (default format)
process only shows the PID
tag only shows priority/tag
raw displays the raw log message, no other metadata fields
The time call displays the date, time, priority/label and the PID of the process to issue a message
The threadtime call displays the date, time, priority, label, and remains PID messages sent by the TID thread
long displays all metadata fields with blank lines and separate messages
logcat priority
priority syntax
V – Verbose lowest priority
D –Debug
I -info
W –Warning
And –Error
F –Fatal
S –Silent
eg:adb logcat ActivityManager:I My App:D *:S
Error in Logcat
: 1.adb logcat -f test.txt The wrong place logcat -f is to store the log locally on the development machine, so the file path should be the valid storage path of the development machine
2. In the case of multiple devices, use -s mobileCode to control the log output of fixed devices
Reference blog https://www.cnblogs.com/JianXu/p/5468839.html