Home » Android » Android Framework » How to enable ALOGV verbose debug messages in Android Logcat ?

How to enable ALOGV verbose debug messages in Android Logcat ?

By default, ALOGV “VERBOSE messages” are removed from the release builds of Android. So, if we want to make sure those messages are available in logcat, so we can debug the respective application / subsystem, then we need to enable this verbose messaging for per file basis.

So to enable “ALOGV” message, open the individual source file from which we want to have the debug messages enable and define “LOG_NDEBUG” as 0 at the top.

# define LOG_NDEBUG 0

This has been mentioned at platform/system/core/include/cutils/log.h file as,

/*
 * Normally we strip ALOGV (VERBOSE messages) from release builds.
 * You can modify this (for example with "#define LOG_NDEBUG 0"
 * at the top of your source file) to change that behavior.
 */
#ifndef LOG_NDEBUG
#ifdef NDEBUG
#define LOG_NDEBUG 1
#else
#define LOG_NDEBUG 0
#endif
#endif

So, if we want to enable ALOGV messages from frameworks/av/media/libmedia/mediaplayer.cpp ,

status_t MediaPlayer::setDataSource(int fd, int64_t offset, int64_t length)
{
    ALOGV("setDataSource(%d, %" PRId64 ", %" PRId64 ")", fd, offset, length);
}

then, open this file frameworks/av/media/libmedia/mediaplayer.cpp and uncomment the below line,

//#define LOG_NDEBUG 0

change to

#define LOG_NDEBUG 0

Subscribe our Rurban Life YouTube Channel.. "Rural Life, Urban LifeStyle"

Leave a Comment