There are three step in total

step one:

add "LOCAL_LDLIBS := -llog " to your android.mk file

like:

LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_LDLIBS := -llog
LOCAL_MODULE := hellolog
LOCAL_SRC_FILES := native.c
include $(BUILD_SHARED_LIBRARY)


step two:

include <android/log.h> as header in you c file, and define LOG_TAG、LOGE(...)like:

#include <android/log.h>
#define LOG_TAG "plus.c"
#define LOGE(...) __android_log_print(ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__)


you can also define a yourlog.h file, define all kinds of log, then include this into your c file, like:

=====mylog.h=======

#include <jni.h>
#include <android/log.h>

#define LOG_TAG "hgllog.h"
#define LOGI(...) __android_log_print(ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__)
#define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__)
#define LOGE(...) __android_log_print(ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__)
#define LOGV(...) __android_log_print(ANDROID_LOG_VERBOSE, LOG_TAG, __VA_ARGS__)

step three:

use yourself define LOGE() print info as you want, like:

LOGE("this is log info string....");

LOGE("this is log info string.... and str is %s", str);


更多相关文章

  1. 代码中设置drawableleft
  2. android 3.0 隐藏 系统标题栏
  3. Android开发中activity切换动画的实现
  4. Android(安卓)学习 笔记_05. 文件下载
  5. Android中直播视频技术探究之—摄像头Camera视频源数据采集解析
  6. 技术博客汇总
  7. android 2.3 wifi (一)
  8. AndRoid Notification的清空和修改
  9. Android中的Chronometer

随机推荐

  1. android 应用的网络请求工具
  2. 手把手教你搭建 Android(安卓)SVN 环境
  3. android task与back stack 开发文档翻译
  4. Android(安卓)tablet Fragment 中 TableL
  5. 2011年沈大海讲师Android的腾讯微博客户
  6. Android学习笔记(三十):弹出信息-Toast和告警
  7. Android(安卓)Jetpack重磅升级!新的类库以
  8. delphi xe5 android 开发实现手机打电话
  9. Android(安卓)SDK sample 之 SoftKeyboar
  10. android中menu.add()的使用说明