首页 > 代码库 > Android中log使用方法

Android中log使用方法

private static final String ACTIVITY_TAG="MainActivity";

 

        Log.v(MainActivity.ACTIVITY_TAG, "This is Verbose.%d");
        Log.d(MainActivity.ACTIVITY_TAG, "This is Debug.");
        Log.i(MainActivity.ACTIVITY_TAG, "This is Information");
        Log.w(MainActivity.ACTIVITY_TAG, "This is Warnning.");
        Log.e(MainActivity.ACTIVITY_TAG, "This is Error.");

Eclipse logcat中查看指定Tag

tag:MainActivity

另外也可以在java层

System.out.println("tag by System out");

tag:System.out

 

查看某个变量,需要将变量转换为String类型

int k = 563;
Log.v(MainActivity.ACTIVITY_TAG, "This is Verbose k=" + k);

Android中log使用方法