Disable native logcat outputs in Android

Fernando Gallego picture Fernando Gallego · Jul 20, 2012 · Viewed 7.5k times · Source

I am using a Samsung Galaxy S3 device for development and my app is using the camera. In the logcat, there is an output made by the native system with the tag Camera-JNI that is written to logcat like 20 times per second, causing the logcat to clean the oldest entries very fast.

Is it possible to disable logs from already installed apps or system logs to prevent this? Filters doesn't work, as the logcat is still filled and lines are still being clared.

Thank you.

EDIT

The documentation says this:

You can change the default level by setting a system property: setprop log.tag.<YOUR_LOG_TAG> <LEVEL>. You can also create a local.prop file that with the following in it: log.tag.<YOUR_LOG_TAG>=<LEVEL> and place that in /data/local.prop.

EDIT 2

I already did this (rooting the device, pushing the local.prop file to /data and rebooting) but the tag is still appearing

Answer

wojciii picture wojciii · Jul 24, 2012

I can see the following by examining the android source code (2.3.x):

Executing

shell setprop log.tag.XYZ

will not work here (frameworks/base/core/jni/android_hardware_Camera.cpp), as logging is being done using the LOGV() macro. This method of logging does not use properties to detect if some component wishes to disable logging. That is as far as I am able to trace the calls trough the android code.

So using setprop(...) will not work for disabling logging from an android system component but it should work when the logs come from user apps etc. written in Java which use base/core/java/android/util/Log.java and frameworks/base/core/jni/android_util_Log.cpp to log. My guess is that android_util_Log_isLoggable() is what is being used to filter.

IMHO I see no other alternative than building from source for your device and disabling the LOGV macros in the camera code you are using.