關於android的日誌輸出&LogCat

來源:互聯網
上載者:User

android提供了自己的log輸出api-->位於android.util.Log這個類中.
這個類比較常用的列印日誌的方法有5個,這5個方法都會把日誌列印到LogCat中:
Log.v(tag,message);        //verbose模式,列印最詳細的日誌
Log.d(tag,message);        //debug層級的日誌
Log.i(tag,message);        //info層級的日誌
Log.w(tag,message);        //warn層級的日誌
Log.e(tag,message);        //error層級的日誌
其中tag和message分別是兩個String值.從android開發協助文檔中來看,tag和message的定義分別是:
tag     Used to identify the source of a log message. It usually identifies the class or activity where the log call occurs.
msg     The message you would like logged.
可看出tag用來標記log訊息的源頭的.而message則是這條log的內容.
從日誌的輸出數量來算,error,warn,info,debug,verbose,數量從少到多.
我把先前的Activity其中的各個方法改一下,給每個方法中加上了Log.v來記錄日誌輸出,結果如.

    可以看到,先前調用了Log.v函數的那些on**方法最終是執行了,並且也列印日誌了.

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.