During the development of the standard Linux kernel, printk is used, which is the same as the name of printf output printing and also provides the formatting output function, it only has a print level and saves the information to the/proc/kmsg log, use the cat command to view its information [cat/proc/kmsg] # define KERN_EMERG "<0>"/* system is unusable */# define KERN_ALERT "<1>"/* action must be taken immediately */# define KERN_CRIT "<2>"/* critical conditions */# deinfe KERN_ERR "<3>"/* error conditions */# deinfe KERN_WARNING "<4> "/* warning conditions */# deinfe KERN_NOTI CE "<5>"/* normal but significant condition */# deinfe KERN_INFO "<6>"/* informational */# deinfe KERN_DEBUG "<7>"/* debug-level messages */2. log output in android the Android system provides a lightweight logger log System in the user space, it is a device driver implemented in the kernel. It can be used with the logcat tool in the user space to conveniently track debugging programs. The C/C ++ log interface in the Android system is used by macros. In system/core/include/android/log. h defines the log Level:/** Android log priority values, in ascending priority order. */typedef enum android_LogPriority {priority = 0, ANDROID_LOG_DEFAULT,/* only for SetMinPriority () */priority, ANDROID_LOG_DEBUG, ANDROID_LOG_INFO, priority, ANDROID_LOG_ERROR, priority, priority, /* only for SetMinPriority (); must be last */} Ndroid_LogPriority; For ease of use, in system/core/include/cutils/log. h defines the corresponding macro: # define LOGV (...) (void) LOG (LOG_VERBOSE, LOG_TAG, _ VA_ARGS _) # define LOGD (...) (void) LOG (LOG_DEBUG, LOG_TAG, _ VA_ARGS _) # define LOGI (...) (void) LOG (LOG_INFO, LOG_TAG, _ VA_ARGS _) # define LOGW (...) (void) LOG (LOG_WARN, LOG_TAG, _ VA_ARGS _) # define LOGE (...) (void) LOG (LOG_ERROR, LOG_TAG, _ VA_ARGS _) because if you need to use log output, it contains its header file: # Include <cutils/log. h> link the dynamic library: liblog. so you can # define LOG_TAG "XX_LOG_TAG" // here you can define the output TAG # include <cutils/log. h> JAVA layer printing: import android. util. log; private static final String TAG = "XX_LOG_TAG"; Log. e (TAG, "This is the error log printed by Log. I in android user space. "); 3. How to Get loga on the box, go to shell to get logadb kill-serveradb connect dest-ipadb shell [Login shell] mount-o remount/system [Change permission] logcat> 1. log command line enter CTRL + C back to cmd command line, adb pull path/1.log B, directly get logadb connect after the cmd command line connects; adb shell www.2cto. comadb logcat> path/1. after the log operation is complete, enter CTRL + C in the command line to return to the cmd command line, adb pull path/1.log c. Directly output log on the terminal and press enter to switch to shelllogcat [now you can see the print] 4. Run in Eclipse environment (Android plug-in installed ), you can directly view the 5. Common tips in Eclipse. 1. logcat prints the [output level + LOG_TAG name + process word + printed information] to make full use of the information to analyze the problem. i/SystemServer (939): Activity ManagerI/ActivityManager (939): M Emory class: 96E/AndroidRuntime (939): Error reporting WTF first column by Log. I (e/w ..) or LOGI/LOGE/LOGW... the second column is determined by LOG_TAG/TAG (JAVA). For a group of modules with the same prefix [xxx] funtion, the third column is the system process number getpid, print the thread value pthread_slef (). The last step is to manually add the printing information. 2. Tune the efficiency or execution time. 1. We recommend that you add a prefix for key printing to facilitate search. Use [######] 2. Use logcat output time directly, debug execution speed, and analyze Efficiency