adb command to grab logs

1. Logcat capture log method: adb logcat command, you can add conditional filter

1. Install the SDK (refer to the android sdk environment installation)

2. Use the data cable to link the mobile phone, create a 1.log file in the sdcard of the mobile assistant or export it directly to the computer when capturing the log

3. The program runs cmd and enters the directory containing adb.exe

4. Enter adb devices to see if the device is connected

5. Enter the capture command: adb logcat -s *:E > /mmt/sdcard/1.log or logcat -s '*:E' >d:/1.log,

6. The operation of opening the app with a mobile phone crashes once (press ctrl+c if you want to stop halfway)

7. View the log capture file, and it is not clear which time period caused the consequences

8. Add the command: -v time to display the time

9. Enter the command logcat -v time -s *:E > /mmt/sdcard/1.log (eg:adb logcat -v time -s appname:E>d:/1.log)

10. View the results

ps:

adb logcat -v time -s appname:E>d:/1.log

-v display log format -v time use time as display format

-s filter by default, do not display the default tag. The system sets the default filtering level of the tag to Verbos, and the tag needs to be displayed. If setting -S is equivalent to *:V

appname:E Display logs with priority greater than or equal to "error" in the appname operation

2. Log filtering - according to the level of Log information 

• V-(verbose) - verbose (lowest priority) • D-(debug)-debug • I-(information)-information • W-(warning)-warning • E-(error)-error

• F — critical error • S — undocumented (highest priority, nothing will be logged)

3. Log filtering - use of log filter (adb logcat tag:pripriity)

The format of the filter expression is tag:priority ... , where tag is a tag (can be specific, * means all), priority is the smallest priority, and can be a combination

adblogcat ActivityManager:I MyApp:D *:S

adblogcat * :W -----All logs with priority greater than or equal to "warning"

adblogcat * :E -----All logs with priority greater than or equal to "error"

Four, log output-log control log format adb logcat -v format

brief — show priority/flag and PID of raw process (default format)

process - only show process PIDtag - only show priority/tag

thread — show processes only: threads and priority/flag

raw — display raw log messages, with no other metadata fields

time — display date, call time, priority/flag, PID

long — display all metadata fields and separate message content with blank lines

eg:adb logcat -v thread 

Five.log output - additional buffer: adb logcat -b 

radio — View messages contained in radio/telephony related buffers

events — View messages related to events

main — view the main buffer (default buffer)

adb logcat -b  radio

Adding nothing means the default buffer

Six.log output -log option list

-b <buffer> Specifies the log buffer to view, which can be system, events, radio, main. The default value is system and main.

-c Clear the log on the screen. 

-d output log to screen. 

-f <filename> Specify the <filename> to output log information, the default is stdout. 

-g Output the specified log buffer, exit after output. 

-n <count> Set the maximum number of logs <count>. The default value is 4 and needs to be used together with the -r option. 

-r <kbytes> Output log every <kbytes>, the default value is 16, need to be used together with -f option. 

-s sets the default filtering level to silent. 

-v <format> set log input format

Guess you like

Origin blog.csdn.net/weixin_53379238/article/details/129244763