当前位置: 首页 > article >正文

Android - 通过Logcat Manager简单获取Android手机的Log

由于工作需要,经常需要获取Android手机的Log。

平常都是通过adb命令来获取,每次都要写命令。

偶然的一个机会,我从外网发现了一个工具 Logcat Manager,只需要通过简单的双击即可获取Android的Log,这里也分享一下。

目录

1, 设定手机为开发者模式,并打开USB debugging

1-1,连续快速点6次 Build number 打开Developer 开发者模式

1-2,设置为USB访问可

2,用USB线连接Android手机到PC

3,通过Logcat Manager 获取Log

3-1,展开zip包

3-2,设置快捷方式(不是必须的)

3-3,获取Log

1),双击打开bat文件

2),选择获取Log的选项

3),确认获取的Log


下面说一下通过该工具获取Android手机Log的步骤。

1, 设定手机为开发者模式,并打开USB debugging

如何设置开发者模式,可以参照如下文章。

Android - Pixel 6a 手机OS 由 Android 15 降级到 Android 14 操作记录_安卓15怎么降到安卓14-CSDN博客

为了阅读方便,我也给转记到这里来:

1-1,连续快速点6次 Build number 打开Developer 开发者模式

点完之后会提醒你已经是开发者模式了

1-2,设置为USB访问可

回到上一层,点System,下拉到 Developer Option,点进去

把 USB debugging 打开

2,用USB线连接Android手机到PC

注意用一条紧实的线,不然的话,Log的取得就会中断。

3,通过Logcat Manager 获取Log

3-1,展开zip包

这里面咱们要使用的就是这个AIO_Logcat_Manager.bat文件

这里我也贴一下该bat文件的代码。

其实你细看的话,它是调用adb来获取log,所有本身并不算是新知识,属于一个功能的包装,可以提高效率,减少运用难度。

@echo off
COLOR 0F
setlocal enabledelayedexpansion
IF (%1)==(0) goto logo
mode con:cols=82 lines=46
mkdir Logcat_Output
set model=adb shell "cat /system/build.prop | grep "ro.product.model""
set appname=None

:logo
cls
ECHO.
ECHO.
ECHO.
echo                             `---..` ``````````..---`
echo                             `----------------------.
echo                             `----------------------.
echo                            `------------------------.
echo                            --------O--------O--------.
echo                            ---------------------------
echo                            ------------bd------------.
echo                            .-------------------------.
echo                             .--------\----/---------. 
echo                              `.--------------------`
echo                           ``    ``...--------...`
echo                            `..     `---------`
echo                             `...``.--.--.--.--
echo                               `....--`--`--`--
echo                                    .-`--`--`--
echo                                 `` .-`--`--`--``..
echo.
echo.
echo                          .//`     -:::-   //::///:`                     
echo                          mMMM+    +MMMmodMMm: +MMMhhMMM-                    
echo                         +MdMMMs    MMMy `NMMM``MMMhhMMd`                    
echo                        /MModMMMo  `MMMy  mMMM..MMMdyMMMh                    
echo                      `+MMs+oNMMMo.:MMMd:sMMMo +MMMh/MMMN`                   
echo                      /yyy/ -syyys/sysssyys+. `yysssyys+`                    
echo.
echo.
echo        -syyys-     -osyyo:     :oyysos/   `:oyys+/.    /ys:     +yssssssy-  
echo        `sMMMs`   -mMMssNMMm- /NMMs/omMM` +NMNoohMMN   `MMMMs   +MNyMMMddMN  
echo         :MMM+    dMMM` :MMMN.MMMd  -:o+.-MMMy         hMsNMMy  `:`.MMMy --  
echo         -MMM+  +:hMMMy  NMMm`NMMM::yMMMy:NMMM+`      yMNhmMMMy    :MMMy     
echo        `sMMMdohMy`sNMMmdMMy. .hMMMddMNo  -dMMMMNMMo:hMM+./NMMMh- :hMMMm+    
echo        `:::::://   `-///-`     `:///-      `:///.  -///. ./` `:.    
echo.
echo.
ECHO.
echo                 ALL IN ONE ADB LOGCAT MANAGER FOR ANDROID DEVICES
echo                                 By: majdinj - xda
echo.
ECHO.
ECHO.
pause

:ReadMe
cls
ECHO.
ECHO.
ECHO.
ECHO           ************************************************************
ECHO           ************************************************************
ECHO           **                                                        **
ECHO           **     Before you start, make sure of the followings:     **
ECHO           **                                                        **
ECHO           ************************************************************
ECHO           ************************************************************
ECHO.
ECHO.
ECHO.
ECHO           ************************************************************
ECHO           *                                                          *
ECHO           * 1. Your device USB driver is installed on your computer. *
ECHO           *                                                          *
ECHO           * 2. Your device is set on USB debugging mode.             *
ECHO           *                                                          *
ECHO           * 3. You connect your device to the computer by USB cable. *
ECHO           *                                                          *
ECHO           * 4. Your computer recognizes your device.                 *
ECHO           *                                                          *
ECHO           ************************************************************
ECHO.
ECHO.
ECHO.
ECHO.
echo Are you ready.. let's proceed? (any letter for YES, n or no for NO)
set /P INPUTP=Make your choice: %=%
IF "%INPUTP%"=="" (call :YContinue)
IF "%INPUTP%"==" " (call :YContinue)
IF "%INPUTP%"=="  " (call :YContinue)
IF "%INPUTP%"=="   " (call :YContinue)
IF "%INPUTP%"=="    " (call :YContinue)
IF "%INPUTP%"=="     " (call :YContinue)
IF %INPUTP%==n (call :NContinue)
IF %INPUTP%==no (call :NContinue)
IF %INPUTP%==nO (call :NContinue)
IF %INPUTP%==N (call :NContinue)
IF %INPUTP%==No (call :NContinue)
IF %INPUTP%==NO (call :NContinue)
:YContinue
ECHO.
ECHO.
ECHO.
echo  Proceeding...
ECHO.
ECHO.
ECHO               **************************************************
ECHO               *     Activating ADB Shell... Please wait...     *
ECHO               **************************************************
goto restart
:NContinue
ECHO.
ECHO.
ECHO.
echo  Quitting...
ECHO.
ECHO.
ECHO.
ECHO                **************************************************
ECHO                *        Come again once you are ready...        *
ECHO                **************************************************
ECHO.
echo.
timeout 4
EXIT



:restart
cd "%~dp0"
cd %~dp0/tools
%model% > nul
IF %ERRORLEVEL% NEQ 0 (goto adberror)
cd "%~dp0"
set appname=None
goto MainMenu

:MainMenu
COLOR 0E
cls
echo Date: %date%
echo Time: %TIME:~0,2%:%TIME:~3,2%:%TIME:~6,2%
cd %~dp0/tools
set /p "=Device ID: " <nul
%model%
cd "%~dp0"
echo.
echo  --------------------------------------------------------------------------------
echo.
echo                        All In One Android Logcat Manager v1
echo.
echo  --------------------------------------------------------------------------------
echo.
echo              1   Export Normal All levels logcat to txt file
echo              2   Export Normal Time-line logcat to txt file
echo              3   Export Normal Neat logcat to txt file
echo              4   Export Only Error level logcat to txt file
echo              5   Export Only Fatal level logcat to txt file
ECHO.
echo              6   Export All levels Radio logcat to txt file
echo              7   Export Only Error level Radio logcat to txt file
echo              8   Export Only Fatal level Radio logcat to txt file
ECHO.
ECHO              9   Special process filtered by name logcat mode
echo.
echo              10  Read exported logcat txt file in Logcat_Output folder
echo.
echo              11  Advanced Kernel logcat [NEEDS SU ROOT ACCESS PERMISSIONS]
echo.
echo              12  Clean Logcat_Output folder
echo              13  Terminate and exit ADB session
echo.
echo  --------------------------------------------------------------------------------
echo.
SET /P menu=Please make your decision:
IF %menu%==1 (goto all)
IF %menu%==2 (goto time)
IF %menu%==3 (goto neat)
IF %menu%==4 (goto error)
IF %menu%==5 (goto fatal)
IF %menu%==6 (goto Nradio)
IF %menu%==7 (goto Eradio)
IF %menu%==8 (goto Fradio)
IF %menu%==9 (goto MainMenu1)
IF %menu%==10 (goto fileselect)
IF %menu%==11 (goto MainMenu2)
IF %menu%==12 (goto clean)
IF %menu%==13 (goto termexit)


@REM If you got here, it wasn't 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, or 13
echo.
echo.
ECHO                 *************************************************
echo                 *    Are you crazy.. choose something exist.    *
ECHO                 *************************************************
echo.
echo.
PAUSE
goto restart


:all
if not exist %~dp0\Logcat_Output\ (mkdir Logcat_Output)
echo.
echo Exporting all levels logcat,,,
echo.
cd %~dp0/tools
start /b adb logcat > ../Logcat_Output/[All-levels-Logcat].txt
cd "%~dp0"
goto stop


:time
if not exist %~dp0\Logcat_Output\ (mkdir Logcat_Output)
echo.
echo Exporting time-line logcat,,,
echo.
cd %~dp0/tools
start /b adb logcat -v time -d > ../Logcat_Output/[Time-line-Logcat].txt
cd "%~dp0"
goto stop

:neat
if not exist %~dp0\Logcat_Output\ (mkdir Logcat_Output)
echo.
echo Exporting Neat logcat,,,
echo.
cd %~dp0/tools
start /b adb logcat -v long > ../Logcat_Output/[Neat-Logcat].txt
cd "%~dp0"
goto stop

:error
if not exist %~dp0\Logcat_Output\ (mkdir Logcat_Output)
echo.
echo Exporting error level logcat,,,
echo.
cd %~dp0/tools
start /b adb logcat *:E -v long > ../Logcat_Output/[Error-level-Logcat].txt
cd "%~dp0"
goto stop

:fatal
if not exist %~dp0\Logcat_Output\ (mkdir Logcat_Output)
echo.
echo Exporting fatal level logcat,,,
echo.
cd %~dp0/tools
start /b adb logcat *:F -v long > ../Logcat_Output/[Fatal-level-Logcat].txt
cd "%~dp0"
goto stop

:Nradio
if not exist %~dp0\Logcat_Output\ (mkdir Logcat_Output)
echo.
echo Exporting All levels Radio logcat,,,
echo.
cd %~dp0/tools
start /b adb logcat -b radio -v time -d > ../Logcat_Output/[All-levels-Radio-Logcat].txt
cd "%~dp0"
goto stop

:Eradio
if not exist %~dp0\Logcat_Output\ (mkdir Logcat_Output)
echo.
echo Exporting Error level Radio logcat,,,
echo.
cd %~dp0/tools
start /b adb logcat -b radio *:E -v time -d > ../Logcat_Output/[Error-level-Radio-Logcat].txt
cd "%~dp0"
goto stop

:Fradio
if not exist %~dp0\Logcat_Output\ (mkdir Logcat_Output)
echo.
echo Exporting Fatal level Radio logcat,,,
echo.
cd %~dp0/tools
start /b adb logcat -b radio *:F -v time -d > ../Logcat_Output/[Fatal-level-Radio-Logcat].txt
cd "%~dp0"
goto stop




:stop
echo ADB logcat exporting is running now...
echo To stop exporting, press ENTER key..
set /P INPUT0=Stop Now: %=% > nul
IF "%INPUT0%"=="" (call :YStop)
:YStop
echo logcat has been stopped..
goto OpenOutput


:OpenOutput
echo.
echo Open Logcat_Output folder? (any letter for YES, n or no for NO)
set /P INPUT=Make your choice: %=%
IF "%INPUT%"=="" (call :YOpenOutput)
IF %INPUT%==n (call :NOpenOutput)
IF %INPUT%==no (call :NOpenOutput)
IF %INPUT%==nO (call :NOpenOutput)
IF %INPUT%==N (call :NOpenOutput)
IF %INPUT%==No (call :NOpenOutput)
IF %INPUT%==NO (call :NOpenOutput)
:YOpenOutput
cd %~dp0/tools
adb kill-server
adb kill-server
cd "%~dp0"
cd %~dp0/Logcat_Output
IF EXIST "[All-levels-Logcat].txt" (REN "[All-levels-Logcat].txt" "[All-levels-Logcat]_%Date:~-7,2%-%Date:~-10,2%-%Date:~-4,4%_%TIME:~0,2%%TIME:~3,2%%TIME:~6,2%.txt")
IF EXIST "[Time-line-Logcat].txt" (REN "[Time-line-Logcat].txt" "[Time-line-Logcat]_%Date:~-7,2%-%Date:~-10,2%-%Date:~-4,4%_%TIME:~0,2%%TIME:~3,2%%TIME:~6,2%.txt")
IF EXIST "[Neat-Logcat].txt" (REN "[Neat-Logcat].txt" "[Neat-Logcat]_%Date:~-7,2%-%Date:~-10,2%-%Date:~-4,4%_%TIME:~0,2%%TIME:~3,2%%TIME:~6,2%.txt")
IF EXIST "[Error-level-Logcat].txt" (REN "[Error-level-Logcat].txt" "[Error-level-Logcat]_%Date:~-7,2%-%Date:~-10,2%-%Date:~-4,4%_%TIME:~0,2%%TIME:~3,2%%TIME:~6,2%.txt")
IF EXIST "[Fatal-level-Logcat].txt" (REN "[Fatal-level-Logcat].txt" "[Fatal-level-Logcat]_%Date:~-7,2%-%Date:~-10,2%-%Date:~-4,4%_%TIME:~0,2%%TIME:~3,2%%TIME:~6,2%.txt")
IF EXIST "[All-levels-Radio-Logcat].txt" (REN "[All-levels-Radio-Logcat].txt" "[All-levels-Radio-Logcat]_%Date:~-7,2%-%Date:~-10,2%-%Date:~-4,4%_%TIME:~0,2%%TIME:~3,2%%TIME:~6,2%.txt")
IF EXIST "[Error-level-Radio-Logcat].txt" (REN "[Error-level-Radio-Logcat].txt" "[Error-level-Radio-Logcat]_%Date:~-7,2%-%Date:~-10,2%-%Date:~-4,4%_%TIME:~0,2%%TIME:~3,2%%TIME:~6,2%.txt")
IF EXIST "[Fatal-level-Radio-Logcat].txt" (REN "[Fatal-level-Radio-Logcat].txt" "[Fatal-level-Radio-Logcat]_%Date:~-7,2%-%Date:~-10,2%-%Date:~-4,4%_%TIME:~0,2%%TIME:~3,2%%TIME:~6,2%.txt")
start "" "%~dp0/Logcat_Output"
echo.
echo Re-activating ADB Shell, Please Wait...
set appname=None
goto restart
:NOpenOutput
cd %~dp0/tools
adb kill-server
adb kill-server
cd "%~dp0"
cd %~dp0/Logcat_Output
IF EXIST "[All-levels-Logcat].txt" (REN "[All-levels-Logcat].txt" "[All-levels-Logcat]_%Date:~-7,2%-%Date:~-10,2%-%Date:~-4,4%_%TIME:~0,2%%TIME:~3,2%%TIME:~6,2%.txt")
IF EXIST "[Time-line-Logcat].txt" (REN "[Time-line-Logcat].txt" "[Time-line-Logcat]_%Date:~-7,2%-%Date:~-10,2%-%Date:~-4,4%_%TIME:~0,2%%TIME:~3,2%%TIME:~6,2%.txt")
IF EXIST "[Neat-Logcat].txt" (REN "[Neat-Logcat].txt" "[Neat-Logcat]_%Date:~-7,2%-%Date:~-10,2%-%Date:~-4,4%_%TIME:~0,2%%TIME:~3,2%%TIME:~6,2%.txt")
IF EXIST "[Error-level-Logcat].txt" (REN "[Error-level-Logcat].txt" "[Error-level-Logcat]_%Date:~-7,2%-%Date:~-10,2%-%Date:~-4,4%_%TIME:~0,2%%TIME:~3,2%%TIME:~6,2%.txt")
IF EXIST "[Fatal-level-Logcat].txt" (REN "[Fatal-level-Logcat].txt" "[Fatal-level-Logcat]_%Date:~-7,2%-%Date:~-10,2%-%Date:~-4,4%_%TIME:~0,2%%TIME:~3,2%%TIME:~6,2%.txt")
IF EXIST "[All-levels-Radio-Logcat].txt" (REN "[All-levels-Radio-Logcat].txt" "[All-levels-Radio-Logcat]_%Date:~-7,2%-%Date:~-10,2%-%Date:~-4,4%_%TIME:~0,2%%TIME:~3,2%%TIME:~6,2%.txt")
IF EXIST "[Error-level-Radio-Logcat].txt" (REN "[Error-level-Radio-Logcat].txt" "[Error-level-Radio-Logcat]_%Date:~-7,2%-%Date:~-10,2%-%Date:~-4,4%_%TIME:~0,2%%TIME:~3,2%%TIME:~6,2%.txt")
IF EXIST "[Fatal-level-Radio-Logcat].txt" (REN "[Fatal-level-Radio-Logcat].txt" "[Fatal-level-Radio-Logcat]_%Date:~-7,2%-%Date:~-10,2%-%Date:~-4,4%_%TIME:~0,2%%TIME:~3,2%%TIME:~6,2%.txt")
echo.
echo Re-activating ADB Shell, Please Wait...
set appname=None
goto restart


:fileselect
cls
echo.
echo            -----------------------------------------------------------
echo                         Please select a file from the list
echo                             bellow to view its content
echo            -----------------------------------------------------------
echo.
set /A count=0
FOR %%F IN (Logcat_Output/*.txt) DO (
set /A count+=1
set a!count!=%%F
if /I !count! LEQ 9 (echo ^- !count!  - %%F )
if /I !count! GTR 9 (echo ^- !count! - %%F )
)
FOR %%F IN (Logcat_Output/*.xml) DO (
set /A count+=1
set a!count!=%%F
if /I !count! LEQ 9 (echo ^- !count!  - %%F )
if /I !count! GTR 9 (echo ^- !count! - %%F )
)
echo.
echo.
echo           (Any other number or letter to return back to the main menu..)
echo       ----------------------------------------------------------------------
set /P INPUT1=Please Enter The File Number: %=%
if /I %INPUT1% GTR !count! (goto non)
if /I %INPUT1% LSS 1 (goto non)
set txts=!a%INPUT1%!
set jar=0
set ext=jar
IF "!txts:%ext%=!" NEQ "%txts%" set jar=1
cd "%~dp0"
start "" "%~dp0/Logcat_Output/%txts%"
cd "%~dp0"
goto restart
:non
goto restart


:clean
if not exist %~dp0\Logcat_Output\ (mkdir Logcat_Output
echo.
echo A cleaned Logcat_Output folder is created..
echo.
PAUSE
goto restart
)
echo.
echo Cleaning Logcat_Output folder..
cd %~dp0/tools
adb kill-server > nul
adb kill-server > nul
adb kill-server > nul
cd "%~dp0"
rmdir /S /Q Logcat_Output > nul
mkdir Logcat_Output
echo.
echo Cleaned..
echo Re-activating ADB Shell, Please Wait...
echo.
timeout 0 > nul
goto restart


:restart1
cd "%~dp0"
cd %~dp0/tools
%model% > nul
IF %ERRORLEVEL% NEQ 0 (goto adberror)
cd "%~dp0"
set appname=None
goto MainMenu1



:MainMenu1
COLOR 0E
cls
echo Date: %date%
echo Time: %TIME:~0,2%:%TIME:~3,2%:%TIME:~6,2%
cd %~dp0/tools
set /p "=Device ID: " <nul
%model%
cd "%~dp0"
echo.
echo  --------------------------------------------------------------------------------
echo.
echo                          Process Logcat Filtered By Name
echo.
echo  --------------------------------------------------------------------------------
echo  --------------------------------------------------------------------------------
ECHO  ^| Process Name To Filter: %appname% ^|
echo  --------------------------------------------------------------------------------
echo.
echo              0   Type a Process Name to Filter
ECHO.
echo              1   Export Normal All levels Filtered logcat to txt file
echo              2   Export Only Error level Filtered logcat to txt file
echo              3   Export Only Fatal level Filtered logcat to txt file
echo.
echo              4   Export All levels Filtered Radio logcat to txt file
echo              5   Export Error level Filtered Radio logcat to txt file
echo              6   Export Fatal level Filtered Radio logcat to txt file
ECHO.
echo              7   Return Back To The Main Menu
echo.
echo  --------------------------------------------------------------------------------
ECHO.
SET /P menuf=Please make your decision:
IF %menuf%==0 (goto filtername)
IF %menuf%==1 (goto filterall)
IF %menuf%==2 (goto filtererror)
IF %menuf%==3 (goto filterfatal)
IF %menuf%==4 (goto filterradio)
IF %menuf%==5 (goto filterErradio)
IF %menuf%==6 (goto filterFatradio)
IF %menuf%==7 (goto restart)

@REM If you got here, it wasn't 0, 1, 2, 3, 4, 5, 6, or 7
echo.
echo.
ECHO                 *************************************************
echo                 *    Are you crazy.. choose something exist.    *
ECHO                 *************************************************
echo.
echo.
PAUSE
set appname=None
goto restart1


:filtername
ECHO.
set /P newname=Type the process name to filter: %=%
set appname=%newname%
if "%newname%"=="" (goto ss1)
if "%newname%"==" " (goto ss1)
if "%newname%"=="  " (goto ss1)
if "%newname%"=="   " (goto ss1)
if "%newname%"=="    " (goto ss1)
if "%newname%"=="     " (goto ss1)
if "%newname%"=="      " (goto ss1)
if "%newname%"=="       " (goto ss1)
if "%newname%"=="        " (goto ss1)
if "%newname%"=="         " (goto ss1)
if "%newname%"=="          " (goto ss1)
if "%newname%"=="           " (goto ss1)
if "%newname%"=="            " (goto ss1)
if "%newname%"=="             " (goto ss1)
if "%newname%"=="              " (goto ss1)
if "%newname%"=="               " (goto ss1)
if "%newname%"=="                " (goto ss1)
if "%newname%"=="                 " (goto ss1)
if "%newname%"=="                  " (goto ss1)
if "%newname%"=="                   " (goto ss1)
if "%newname%"=="                    " (goto ss1)
if "%newname%"=="                     " (goto ss1)
if "%newname%"=="                      " (goto ss1)
if "%newname%"=="                       " (goto ss1)
if "%newname%"=="                        " (goto ss1)
if "%newname%"=="                         " (goto ss1)
if "%newname%"=="                          " (goto ss1)
if "%newname%"=="                           " (goto ss1)
if "%newname%"=="                            " (goto ss1)
if "%newname%"=="                             " (goto ss1)
if "%newname%"=="                              " (goto ss1)
goto MainMenu1


:filterall
if not exist %~dp0\Logcat_Output\ (mkdir Logcat_Output)
echo.
if %appname%==None goto ss
echo Exporting all levels %appname% filtered logcat,,,
echo.
cd %~dp0/tools
start /b adb logcat %appname% *:S -v long > ../Logcat_Output/[All-levels-Logcat-filtered].txt
cd "%~dp0"
goto stop1


:filtererror
if not exist %~dp0\Logcat_Output\ (mkdir Logcat_Output)
echo.
if %appname%==None goto ss
echo Exporting %appname% filtered error level logcat,,,
echo.
cd %~dp0/tools
start /b adb logcat %appname%:E *:S -v long > ../Logcat_Output/[Error-level-Logcat-filtered].txt
cd "%~dp0"
goto stop1


:filterfatal
if not exist %~dp0\Logcat_Output\ (mkdir Logcat_Output)
echo.
if %appname%==None goto ss
echo Exporting %appname% filtered fatal level logcat,,,
echo.
cd %~dp0/tools
start /b adb logcat %appname%:F *:S -v long > ../Logcat_Output/[Fatal-level-Logcat-filtered].txt
cd "%~dp0"
goto stop1


:filterradio
if not exist %~dp0\Logcat_Output\ (mkdir Logcat_Output)
echo.
if %appname%==None goto ss
echo Exporting All levels %appname% filtered Radio logcat,,,
echo.
cd %~dp0/tools
start /b adb logcat -b radio %appname% *:S -v time -d > ../Logcat_Output/[All-levels-Radio-Logcat-filtered].txt
cd "%~dp0"
goto stop1


:filterErradio
if not exist %~dp0\Logcat_Output\ (mkdir Logcat_Output)
echo.
if %appname%==None goto ss
echo Exporting %appname% filtered Error level Radio logcat,,,
echo.
cd %~dp0/tools
start /b adb logcat -b radio %appname%:E *:S -v time -d > ../Logcat_Output/[Error-level-Radio-Logcat-filtered].txt
cd "%~dp0"
goto stop1


:filterFatradio
if not exist %~dp0\Logcat_Output\ (mkdir Logcat_Output)
echo.
if %appname%==None goto ss
echo Exporting %appname% filtered Fatal level Radio logcat,,,
echo.
cd %~dp0/tools
start /b adb logcat -b radio %appname%:F *:S -v time -d > ../Logcat_Output/[Fatal-level-Radio-Logcat-filtered].txt
cd "%~dp0"
goto stop1



:ss
echo.
echo.
ECHO         *****************************************************************
echo         *      Please Type A Process Name To Logcat It. (Option 0)      *
ECHO         *****************************************************************
echo.
echo.
PAUSE
goto restart1

:ss1
echo.
echo.
ECHO         *****************************************************************
echo         * You Haven't Type Anything,, Please Type A Valid Process Name. *
ECHO         *****************************************************************
echo.
echo.
pause
goto restart1


:stop1
echo ADB logcat exporting is running now...
echo To stop exporting, press ENTER key..
set /P INPUTS=Stop Now: %=% > nul
IF "%INPUTS%"=="" (call :YStop1)
:YStop1
echo logcat has been stopped..
goto OpenOutput1


:OpenOutput1
echo.
echo Open Logcat_Output folder? (any letter for YES, n or no for NO)
set /P INPUTS1=Make your choice: %=%
IF "%INPUTS1%"=="" (call :YOpenOutput1)
IF %INPUTS1%==n (call :NOpenOutput1)
IF %INPUTS1%==no (call :NOpenOutput1)
IF %INPUTS1%==nO (call :NOpenOutput1)
IF %INPUTS1%==N (call :NOpenOutput1)
IF %INPUTS1%==No (call :NOpenOutput1)
IF %INPUTS1%==NO (call :NOpenOutput1)
:YOpenOutput1
cd %~dp0/tools
adb kill-server
adb kill-server
cd "%~dp0"
cd %~dp0/Logcat_Output
IF EXIST "[All-levels-Logcat-filtered].txt" (REN "[All-levels-Logcat-filtered].txt" "[All-levels-Logcat-(%appname%)-filtered]_%Date:~-7,2%-%Date:~-10,2%-%Date:~-4,4%_%TIME:~0,2%%TIME:~3,2%%TIME:~6,2%.txt")
IF EXIST "[All-levels-Radio-Logcat-filtered].txt" (REN "[All-levels-Radio-Logcat-filtered].txt" "[All-levels-Radio-Logcat-(%appname%)-filtered]_%Date:~-7,2%-%Date:~-10,2%-%Date:~-4,4%_%TIME:~0,2%%TIME:~3,2%%TIME:~6,2%.txt")
IF EXIST "[Error-level-Logcat-filtered].txt" (REN "[Error-level-Logcat-filtered].txt" "[Error-level-Logcat-(%appname%)-filtered]_%Date:~-7,2%-%Date:~-10,2%-%Date:~-4,4%_%TIME:~0,2%%TIME:~3,2%%TIME:~6,2%.txt")
IF EXIST "[Fatal-level-Logcat-filtered].txt" (REN "[Fatal-level-Logcat-filtered].txt" "[Fatal-level-Logcat-(%appname%)-filtered]_%Date:~-7,2%-%Date:~-10,2%-%Date:~-4,4%_%TIME:~0,2%%TIME:~3,2%%TIME:~6,2%.txt")
IF EXIST "[Error-level-Radio-Logcat-filtered].txt" (REN "[Error-level-Radio-Logcat-filtered].txt" "[Error-level-Radio-Logcat-(%appname%)-filtered]_%Date:~-7,2%-%Date:~-10,2%-%Date:~-4,4%_%TIME:~0,2%%TIME:~3,2%%TIME:~6,2%.txt")
IF EXIST "[Fatal-level-Radio-Logcat-filtered].txt" (REN "[Fatal-level-Radio-Logcat-filtered].txt" "[Fatal-level-Radio-Logcat-(%appname%)-filtered]_%Date:~-7,2%-%Date:~-10,2%-%Date:~-4,4%_%TIME:~0,2%%TIME:~3,2%%TIME:~6,2%.txt")
start "" "%~dp0/Logcat_Output"
echo.
echo Re-activating ADB Shell, Please Wait...
set appname=None
goto restart1
:NOpenOutput1
cd %~dp0/tools
adb kill-server
adb kill-server
cd "%~dp0"
cd %~dp0/Logcat_Output
IF EXIST "[All-levels-Logcat-filtered].txt" (REN "[All-levels-Logcat-filtered].txt" "[All-levels-Logcat-(%appname%)-filtered]_%Date:~-7,2%-%Date:~-10,2%-%Date:~-4,4%_%TIME:~0,2%%TIME:~3,2%%TIME:~6,2%.txt")
IF EXIST "[All-levels-Radio-Logcat-filtered].txt" (REN "[All-levels-Radio-Logcat-filtered].txt" "[All-levels-Radio-Logcat-(%appname%)-filtered]_%Date:~-7,2%-%Date:~-10,2%-%Date:~-4,4%_%TIME:~0,2%%TIME:~3,2%%TIME:~6,2%.txt")
IF EXIST "[Error-level-Logcat-filtered].txt" (REN "[Error-level-Logcat-filtered].txt" "[Error-level-Logcat-(%appname%)-filtered]_%Date:~-7,2%-%Date:~-10,2%-%Date:~-4,4%_%TIME:~0,2%%TIME:~3,2%%TIME:~6,2%.txt")
IF EXIST "[Fatal-level-Logcat-filtered].txt" (REN "[Fatal-level-Logcat-filtered].txt" "[Fatal-level-Logcat-(%appname%)-filtered]_%Date:~-7,2%-%Date:~-10,2%-%Date:~-4,4%_%TIME:~0,2%%TIME:~3,2%%TIME:~6,2%.txt")
IF EXIST "[Error-level-Radio-Logcat-filtered].txt" (REN "[Error-level-Radio-Logcat-filtered].txt" "[Error-level-Radio-Logcat-(%appname%)-filtered]_%Date:~-7,2%-%Date:~-10,2%-%Date:~-4,4%_%TIME:~0,2%%TIME:~3,2%%TIME:~6,2%.txt")
IF EXIST "[Fatal-level-Radio-Logcat-filtered].txt" (REN "[Fatal-level-Radio-Logcat-filtered].txt" "[Fatal-level-Radio-Logcat-(%appname%)-filtered]_%Date:~-7,2%-%Date:~-10,2%-%Date:~-4,4%_%TIME:~0,2%%TIME:~3,2%%TIME:~6,2%.txt")
echo.
echo Re-activating ADB Shell, Please Wait...
set appname=None
goto restart1


:restart2
cd "%~dp0"
cd %~dp0/tools
%model% > nul
IF %ERRORLEVEL% NEQ 0 (goto adberror)
cd "%~dp0"
set appname=None
goto MainMenu2

:MainMenu2
COLOR 0E
cls
echo Date: %date%
echo Time: %TIME:~0,2%:%TIME:~3,2%:%TIME:~6,2%
cd %~dp0/tools
set /p "=Device ID: " <nul
%model%
cd "%~dp0"
echo.
echo  --------------------------------------------------------------------------------
echo.
echo                 Advanced Kernel Logcat (SU PERMISSIONS IS NEEDED!)
echo.
echo  --------------------------------------------------------------------------------
ECHO   PLEASE, ACCEPT / GUARANTEE SU ROOT ACCESS PERMISSIONS IF PROMPT IN YOUR DEVICE
echo  --------------------------------------------------------------------------------
echo.
echo              1  Read Only Kernel contineous message logcat (kmsg)
echo              2  Read Only Kernel last message logcat (last_kmsg)
echo              3  Read Only Kernel buffer message logcat (dmesg)
ECHO.
echo              4  Export Kernel contineous message logcat (kmsg) to Output folder
echo              5  Export Kernel last message logcat (last_kmsg) to Output folder
echo              6  Export Kernel buffer message logcat (dmesg) to Output folder
ECHO.
echo              7  Return Back To The Main Menu
echo.
echo  --------------------------------------------------------------------------------
echo.
SET /P menuk=Please make your decision:
IF %menuk%==1 (goto kmsg)
IF %menuk%==2 (goto lastkmsg)
IF %menuk%==3 (goto dmesg)
IF %menuk%==4 (goto Exkmsg)
IF %menuk%==5 (goto Exlastkmsg)
IF %menuk%==6 (goto Exdmesg)
IF %menuk%==7 (goto restart)


@REM If you got here, it wasn't 1, 2, 3, 4, 5, 6, or 7
echo.
echo.
ECHO                 *************************************************
echo                 *    Are you crazy.. choose something exist.    *
ECHO                 *************************************************
echo.
echo.
PAUSE
goto restart2


:kmsg
cd "%~dp0/tools"
Start "Reading kmsg log.. (To hold, press Ctrl + C).." suscript 1
goto restart2


:lastkmsg
cd "%~dp0/tools"
Start "Reading last_kmsg log.." suscript 2
goto restart2


:dmesg
cd "%~dp0/tools"
Start "Reading dmesg log.." suscript 3
goto restart2


:Exkmsg
cd "%~dp0/tools"
adb shell "mkdir /sdcard/KERNEL_LOGS" > nul
Start "Exporting Kernel contineous message (kmsg) log.." suscript 4
goto restart2

:Exlastkmsg
cd "%~dp0/tools"
adb shell "mkdir /sdcard/KERNEL_LOGS" > nul
Start "Exporting Kernel last message (last_kmsg) log.." suscript 5
goto restart2

:Exdmesg
cd "%~dp0/tools"
adb shell "mkdir /sdcard/KERNEL_LOGS" > nul
Start "Exporting Kernel buffer message (dmesg) log.." suscript 6
goto restart2


:termexit
cd %~dp0/tools
adb kill-server > nul
adb kill-server > nul
adb kill-server > nul
cd "%~dp0"
echo.
echo.
echo Bye Bye, see ya later :-)
echo.
timeout 3
EXIT

:adberror
cls
COLOR 0C
ECHO.
ECHO.
ECHO.
echo  An Error Occured..
ECHO.
echo  ADB Failed Recognizing Your Device...
ECHO.
ECHO.
ECHO.
ECHO.
ECHO                **************************************************
echo                *                                                *
echo                * You Have Violated The Previous Requirements..  *
echo                *                                                *
ECHO                * Make Sure You Fulfilled All Requirements..     *
echo                *                                                *
ECHO                **************************************************
echo.
ECHO.
ECHO.
echo.
echo  Deactivating ADB Shell.. Please Wait..
cd %~dp0/tools
adb kill-server > nul
adb kill-server > nul
adb kill-server > nul
cd "%~dp0"
echo.
ECHO.
ECHO.
echo.
echo  Quitting Now...
ECHO.
ECHO.
ECHO                **************************************************
ECHO                *        Come again once you are ready...        *
ECHO                **************************************************
ECHO.
ECHO.
ECHO.
timeout 10
EXIT

3-2,设置快捷方式(不是必须的)

这一步只是为了方便,你完全可以点上一级目录中的 .bat 文件。

因为Log要出力到这里来,所以我弄了一个快捷方式到这里,这样我用的时候直接打开这个文件夹,就可以直接看到Log了,省了文件夹的切换。

3-3,获取Log

好了,准备工作都做好了,开始获取Android手机的Log吧。

1),双击打开bat文件

这一步只是显示欢迎信息而已,没有其他用途。

直接按下Enter按钮

说明为了获取Android手机的Log,所需的前提。

咱们直接按下Enter按钮继续

这里是说要启动ADB Shell,其实就是咱们平常所知的那些命令,在这里都自动干了。

2),选择获取Log的选项

 如果你按照我上面所说都设定好了,那你应该能来到下面的画面。

这里有很多选项,我平常用的是 1 - Export Normal All level logcat to txt file。

你可以研究研究其他选项。

直接按下 1

这样工具就开始从Android手机抓取Log了。

然后你就可以去操作手机,操作手机所产生的Log就都会记录下来,出力到PC上。

3),确认获取的Log

获取Log之后,直接按下Enter按钮,或者直接点 x 关掉该窗口。

Log大概就是下面这样的。

以上就是通过Logcat Manager获取Android手机的过程。

希望能给大家一些帮助,谢谢阅读!

工具你在网上自己找找应该也能找到,

我也上传到CSDN上面了,欢迎大家下载(3个积分)。

实在没有积分的朋友,请在本贴留言,我个别给你发。

https://download.csdn.net/download/shi_ly/90312915

更多内容请参照东京老树根博客主页

东京老树根-CSDN博客


http://www.kler.cn/a/520421.html

相关文章:

  • 计算机组成原理(2)王道学习笔记
  • leetcode_链表 876.链表的中间节点
  • 第 25 场 蓝桥月赛
  • Redis实战(黑马点评)——涉及session、redis存储验证码,双拦截器处理请求
  • 【fly-iot飞凡物联】(20):2025年总体规划,把物联网整套技术方案和实现并落地,完成项目开发和课程录制。
  • Vue2下篇
  • mysql_store_result的概念和使用案例
  • 设置jmeter界面图标字体大小
  • YOLOv11-ultralytics-8.3.67部分代码阅读笔记-activation.py
  • 【从零到一,C++项目实战】CineShare++(基于C++的视频点播系统)
  • 01-01 五元组
  • langchain介绍
  • 约数个数(简单)
  • 设计模式-创建型模式-抽象工厂模式
  • 使用.NET 8构建高效的时间日期帮助类
  • MySQL--》深度解析InnoDB引擎的存储与事务机制
  • 双指针(一)
  • TRTC实时对话式AI解决方案,助力人机语音交互极致体验
  • 【可实战】Linux 系统扫盲、 Shell扫盲(如何写一个简单的shell脚本)
  • 适用于 Windows 的 11 款最佳照片恢复软件
  • Pyecharts之双轴图表的魅力
  • 速通 AI+Web3 开发技能: 免费课程+前沿洞察
  • Hook 函数
  • 计网week1+2
  • 【Redis】常见面试题
  • 分布式与微服务:构建现代应用的关键架构