1. adb logcat -t 10 -v time
adb logcat -t 10 -v time
打印最后的10行log信息,每行log信息前带上时间
C:\Users\beijing_zbs>adb logcat -t 10 -v time --------- beginning of /dev/log/system --------- beginning of /dev/log/main 10-28 22:01:41.175 D/MsensorDaemon( 8094): HAVE_LIBC_SYSTEM_PROPERTIES 10-28 22:01:41.175 D/MsensorDaemon( 8094): akmd8975 running 10-28 22:01:41.175 D/MsensorDaemon( 8094): Msensor deamon2 statr!!!!!!!!!!!! 10-28 22:01:41.175 D/MsensorDaemon( 8094): open demon attr err = No such file or directory 10-28 22:01:41.213 D/Sensors ( 1578): M_DA: 5507.836599, 1, 3338.077148 10-28 22:01:41.399 W/ADB_SERVICES( 163): create_local_service_socket() name=shell:export ANDROID_LOG_AGS="" ; exec logcat -t 10 -v time 10-28 22:01:41.400 W/ADB_SERVICES( 163): LS(351): bound to 'shell:export ANDROID_LOG_TAGS="" ; exec logcat -t 10 -v time' via 51 10-28 22:01:41.400 W/ADB_SERVICES( 8095): adb: unable to open /proc/8095/oom_adj 10-28 22:01:41.433 D/Sensors ( 1578): M_DA: 5488.635896, 1, 3338.297119 10-28 22:01:41.453 D/Sensors ( 1578): M_DA: 5511.688308, 1, 3338.317139
2. adb logcat -d
-d dump the log and then exit (don't block)
@ECHO OFF ECHO.[export logcat loginfo] ECHO.------------------------------- adb logcat -v time -d >"%date:~0,4%%date:~5,2%%date:~8,2%%time:~0,2%%time:~3,2%%time:~6,2%.log" ECHO.[pause 5s close...] ping -n 5 127.0.0.1>nul @ECHO ON
3. adb logcat -v time -s videocamera
意思是说,会打印出 log 信息中时间,以及包含关键字 "videocamera" 的所有 log
C:\Users\beijing_zbs>adb logcat -v time -s videocamera --------- beginning of /dev/log/system --------- beginning of /dev/log/main 07-01 08:43:57.037 V/videocamera( 2329): VideoCamera onCreate! 07-01 08:43:57.039 I/videocamera( 2329): getExternalSdState() : removed 07-01 08:43:57.040 I/videocamera( 2329): getExternalState() : mounted 07-01 08:43:57.040 I/videocamera( 2329): Sdcard is exists ? false 07-01 08:43:57.157 V/videocamera( 2329): fulin onCreate Storage.getAvailableSpace() 1335459840 07-01 08:43:57.159 V/videocamera( 2329): fulin initThumbnailButton 07-01 08:43:57.170 D/videocamera( 2329): Thumbnail.getLastThumbnail >>> 07-01 08:43:57.204 E/videocamera( 2329): --------------readVideoPreferences---------------minutes = 600 07-01 08:43:57.205 E/videocamera( 2329): --------------readVideoPreferences----------quality6=10 07-01 08:43:57.207 E/videocamera( 2329): -----------------readVideoPreferences---------mCameraId=0 07-01 08:43:57.208 E/videocamera( 2329): -----------------readVideoPreferences---------quality7=10
4. adb logcat ActivityManager:D MyApp:D *:S
上面表达式的最后的元素 *:S ,,是设置所有的标 签为"silent”,所有日志只显示有”View” and “MyApp”的,用 *:S 的另一个用处是 能够确保日志输出的时候是按照过滤器的说明限制的,也让过滤器也作为一项输出到日志中.
5. adb logcat -v time ActivityManager:D TENCENT_NEWS:E CrashHandler:E *:S
6.adb logcat -c 清除adb logcat缓存
7.adb logcat -c && adb logcat -v time -s ActivityManager 测试android app启动时间,点击启动Splash页,到MainActivity打开,两个时间做差
>adb logcat -c && adb logcat -v time -s ActivityManager| findstr "Displayed" 09-26 15:18:40.240 I/ActivityManager( 1200): Displayed com.tencent.reading/.acti vity.SplashActivity: +183ms 09-26 15:18:51.530 I/ActivityManager( 1200): Displayed com.tencent.reading/.ui.M ainActivity2: +1s328ms
8.抓取内存泄漏log的命令行
adb logcat -c && adb logcat -v time -s LeakCanary>D:/leakcanary_com.tencent.news.txt
参考学习地址:http://blog.csdn.net/tumuzhuanjia/article/details/39555445