參看:http://blog.csdn.net/luoshengyang/article/details/6581828
內核空間工具:
printk 配合 cat /proc/kmsg
用戶空間:
可以配合logcat進行查看
1. 查看C/C++的Log
只要定義自己的LOG_TAG宏和包含頭文件system/core/include/cutils/log.h就可以了:
例子:
#define LOG_TAG "MY LOG TAG"
#include <cutils/log.h>
就可以了,例如使用LOGV:
LOGV("This is the log printed by LOGV in android user space.");
2. 查看Java日誌,定義在frameworks/base/core/java/android/util/Log.java:
只要在類中定義的LOG_TAG常量和引用android.util.Log就可以了:
例子:
import android.util.Log;
private static final String LOG_TAG = "MY_LOG_TAG";
Log.i(LOG_TAG, "This is the log printed by Log.i in android user space.");