Android學習:LogCat日誌查詢

來源:互聯網
上載者:User

Android學習:LogCat日誌查詢

一:Log日誌工具類

一個android應用程式運行後 並不會在 ide的控制台內輸出任何資訊. 不能在控制台輸出。但是android提供的Log類。

在程式中輸出日誌, 使用 android.util.Log 類.
該類提供了若干靜態方法

Log.v(String tag, String msg);
Log.d(String tag, String msg);
Log.i(String tag, String msg);
Log.w(String tag, String msg);
Log.e(String tag, String msg);

分別對應 Verbose, Debug, Info, Warning,Error.

tag是一個標識,可以是任一字元串,通常可以使用類名+方法名, 主要是用來在查看日誌時提供一個篩選條件.


二:程式中打日誌

  public void test(View view) {    Log.i("test", "進入test函數");//findViewByIdTextView textView = (TextView) findViewById(R.id.textView1);textView.setText(R.string.textChange);//ToastToast toast = Toast.makeText(MainActivity.this, "點擊了Button",Toast.LENGTH_SHORT); //螢幕置中顯示,X軸和Y軸位移量都是0  toast.setGravity(Gravity.CENTER, 0, 0);toast.show();}


三:LogCat


聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.