【Android】 Android中Log调试详解
生活随笔
收集整理的這篇文章主要介紹了
【Android】 Android中Log调试详解
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
LOG類:
public final class
Log
extends Object
java.lang.Object
? android.util.Log
Constants
int ASSERT Priority constant for the println method.
int DEBUG Priority constant for the println method; use Log.d. 輸出DEBUG故障日志信息
int ERROR Priority constant for the println method; use Log.e. 輸出ERROR錯(cuò)誤日志信息
int INFO Priority constant for the println method; use Log.i. 輸出INFO程序日志信息
int VERBOSE Priority constant for the println method; use Log.v. 輸出VERBOSE冗余日志信息
運(yùn)行結(jié)果:
public final class
Log
extends Object
java.lang.Object
? android.util.Log
Constants
int ASSERT Priority constant for the println method.
int DEBUG Priority constant for the println method; use Log.d. 輸出DEBUG故障日志信息
int ERROR Priority constant for the println method; use Log.e. 輸出ERROR錯(cuò)誤日志信息
int INFO Priority constant for the println method; use Log.i. 輸出INFO程序日志信息
int VERBOSE Priority constant for the println method; use Log.v. 輸出VERBOSE冗余日志信息
int WARN Priority constant for the println method; use Log.w. 輸出WARN警告日志信息
參考示例:
package com.ceac.test7;import android.support.v7.app.ActionBarActivity; import android.os.Bundle; import android.util.Log; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button;public class MainActivity extends ActionBarActivity implements OnClickListener{private Button button;private Button button2;private Button button3;private Button button4;private Button button5;@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);button = (Button) findViewById(R.id.button1);button2 = (Button) findViewById(R.id.button2);button3 = (Button) findViewById(R.id.button3);button4 = (Button) findViewById(R.id.button4);button5 = (Button) findViewById(R.id.button5);button.setOnClickListener(this);button2.setOnClickListener(this);button3.setOnClickListener(this);button4.setOnClickListener(this);button5.setOnClickListener(this);}@Overridepublic void onClick(View v) {switch (v.getId()) {case R.id.button1:Log.d("debug", "DEBUG");break;case R.id.button2:Log.e("error", "ERROR");break;case R.id.button3:Log.i("info", "INFO");break;case R.id.button4:Log.v("verbose", "VERBOSE");break;case R.id.button5:Log.w("warn", "WARN");break;default:break;}} }運(yùn)行結(jié)果:
Android源碼詳解:
總結(jié)
以上是生活随笔為你收集整理的【Android】 Android中Log调试详解的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 【Android】 常用的Intent
- 下一篇: 【Android】Android中WIF