[Android] 使用 adb logcat 檢視記錄檔訊息

[Android] 使用 adb logcat 檢視記錄檔訊息

之前用 eclipse 或是 Android Studio 寫 app 的話,

IDE 裡面都有地方直接秀出 logcat 的記錄檔訊息~

不過現在我是用 Sublime Text 來寫基於 Cordova 的 app,

沒有 IDE 可以幫我秀 logcat 了~

 

不過要看 locat 的訊息也很簡單,執行 adb logcat 就可以看到了,例如:

testuser@localhost ~ $ adb logcat
D/JsMessageQueue( 1652): Set native->JS mode to null
D/JsMessageQueue( 1652): Set native->JS mode to OnlineEventsBridgeMode
D/dalvikvm( 1652): GC_FOR_ALLOC freed 82K, 3% free 13863K/14151K, paused 2ms
D/dalvikvm( 1652): GC_FOR_ALLOC freed 11K, 3% free 14161K/14471K, paused 2ms
W/InputManagerService(  879): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@b407b590
D/dalvikvm( 1652): GC_CONCURRENT freed 79K, 2% free 14540K/14791K, paused 0ms+0ms
W/PluginManager( 1652): THREAD WARNING: exec() call to Notification.confirm blocked the main thread for 31ms. Plugin should use CordovaInterface.getThreadPool().
W/InputManagerService(  879): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@b407e820
W/ThrottleService(  879): unable to find stats for iface rmnet0
D/dalvikvm(  879): GC_CONCURRENT freed 387K, 13% free 14675K/16839K, paused 1ms+1ms

 

只是 logcat 的訊息很多,要自己想辦法過濾一下,

加上 <tag>:<priority> 是一種方法,

像下面就是只秀出 ERROR 等級以上的 log:

adb logcat *:e

 

Priority 的部分可以參考 logcat help 的部分:

<tag> is a log component tag (or * for all) and priority is:
V    Verbose
D    Debug
I    Info
W    Warn
E    Error
F    Fatal
S    Silent (supress all output)
'*' means '*:d' and <tag> by itself means <tag>:v

 

或是也可以用 grep 來過濾~ 

 

(本頁面已被瀏覽過 685 次)

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *

這個網站採用 Akismet 服務減少垃圾留言。進一步了解 Akismet 如何處理網站訪客的留言資料