ADB logcat filter logs via package name and output to TXT file

Source: Internet
Author: User

Recently learned to use the ADB command to capture the app flash back log;

1) on the cmd command line, you can use the ADB logcat command to view the log of the Android system, or you can use the ADB shell to enter the ADB Shell dedicated command line

2) DOS window can be directly input log, or directed output to TXT file;

3) Press CTRL + C interrupt input log record;

Each log of the Android output has a tag and priority associated with it.

The priority is the following character, in order from low to High:
V-Detail verbose (lowest priority)
-D Debug Debug
I-Info info
W-Warning warn
E-Fault Error
F-Critical Error fatal
S-No record silent

How to use each command can be viewed by: https://www.cnblogs.com/mgzc-1508873480/p/7116207.html

the focus of this session:

1. If you want to filter a specific level of logging, use the following command:

ADB logcat *:w//Show all logs with priority greater than or equal to "warning"

2. Add the package name filter log:

Add two files in the ADB directory Getpid.bat and Getpid1.bat:

1.getpid.bat

@echo off
adb Shell "PS | grep xxx "

where "XXX" is the package name

2.getpid1.bat

Method 1: Print the log directly in CMD; log no filter

@echo off
for/f "tokens=2 delims="%%i in (' Getpid.bat ') do set pid=%%i
Echo%pid%
ADB Logcat | Find "%pid%"
Pause

Method 2: Print the log directly in cmd, log filtering, such as filtering E and E-level above the log;

@echo off
for/f "tokens=2 delims="%%i in (' Getpid.bat ') do set pid=%%i
Echo%pid%
ADB Logcat *:e | Find "%pid%"
Pause

You can also modify the Add directed output to TXT file on Method 2: adb logcat *:e | Find "%pid%" > MYAPP1.txt

operating mode:

1. Connect the phone, enter the ADB devices in CMD and check if the device is connected properly;

PS: Connection is not normal, you can refer to the following blog: https://www.cnblogs.com/sxming/p/7928361.html

2. Double-click Getpid1.bat to run; Then open the app to crawl the log

3. Finally CTRL + C ends

ADB logcat filter logs via package name and output to TXT file

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.