Summary of use of Android under log
One: Under the source code development mode
1: Include header file:
- #include <cutils/log.h>
2: define macro Log_tag
- #define LOG_TAG "MY LOG TAG"
3: Link log corresponding to the. So Library
Add the following statement to the Android.mk file:
- Local_shared_libraries +=\
- Libcutils
You can then use LOGD to print the log information directly.
II: Under the NDK development model
1: Include header file:
- #include <android/log.h>
2: Define Macro Log_tag
- #define LOG_TAG "MY LOG TAG"
- #define LOGD (...) __android_log_print (Android_log_debug, Log_tag, __va_args__)
3: Link log corresponding to the. So Library
Add the following statement to the Android.mk file:
- Local_ldlibs: =-llog
You can then use LOGD to print the log information directly.
Three: in Java code
1: Import Package
- Import Android.util.Log;
2: Use
- private static final String TAG = "Your_tag";
- LOG.D (TAG, "show something");
You can see the corresponding content through the Logcat command under the ADB shell during the program's operation. or see the corresponding content in the Logcat window of ADT under Eclipse.
Summary of use of Android under log