How to print log messages in the Android infrastructure

I am trying to print log messages in the main files of the Android framework. For example, I tried recording messages in MediaRecorderClient.cpp under frameworks\base\media\libmediaplayerservice\ . I tried LOGV , LOGE , LOGD , printf and __android_log_print without any success.

Which command should be used to print log messages?

+4
source share
5 answers

A log should be used, but it will print for logcat, not for printing the system.

Example:

 Log.d("filter", example text); // filter is any tag you want to use as filter 

You can open logcat in eclipse from window-show view -> other -> android -> logcat

+6
source

What error are you getting? If it does not compile, make sure you include <android / log.h>, also in Android.mk:

 LOCAL_LDLIBS := -llog 

If it compiles, but does not produce any output, then, as @Warpzit said, you need to look at logcat to see your posts.

+3
source

It also seems that you can only pass char * to JNI LOG methods. Therefore, if you have numbers in the debug line, you should put them in the char buffer (using sprintf).

+1
source

/system/core/include/cutils/log.h defines macros for entering the Android Framework.

So you uncomment the line that says #define LOG_NDEBUG 0 at the top of the source file, and it will turn on VERBOSE logging. You will need to recompile this entire library and put it in the android system.img assembly.

I believe macro calls are ALOGV, ALOGE, etc.

This is similar to this other answer:

How to get verbose logging in logcat for a specific module

0
source

Declare a string first

 Private String Tag = getClass().getsimplename(); 

and than in your method

  Log.d(Tag,"This is my oncreate method"); 
0
source

Source: https://habr.com/ru/post/1383583/


All Articles