参看: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.");