Summary of use of Android under log

Source: Internet
Author: User

Summary of use of Android under log

One: Under the source code development mode

1: Include header file:

    1. #include <cutils/log.h>

2: define macro Log_tag

    1. #define LOG_TAG "MY LOG TAG"

3: Link log corresponding to the. So Library

Add the following statement to the Android.mk file:

    1. Local_shared_libraries +=\
    2. Libcutils

You can then use LOGD to print the log information directly.

II: Under the NDK development model

1: Include header file:

    1. #include <android/log.h>

2: Define Macro Log_tag

    1. #define LOG_TAG "MY LOG TAG"
    2. #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:

    1. Local_ldlibs: =-llog

You can then use LOGD to print the log information directly.

Three: in Java code

1: Import Package

    1. Import Android.util.Log;

2: Use

    1. private static final String TAG = "Your_tag";
    2. 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.