Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable native logcat outputs in Android

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

like image 777
Fernando Gallego Avatar asked Jul 20 '12 09:07

Fernando Gallego


2 Answers

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.

like image 193
wojciii Avatar answered Nov 15 '22 19:11

wojciii


You can try something like adb shell setprop log.tag.Camera-JNI ERROR. If it doesn't work simply filter the log or dump it to a file and use grep to find the lines you are interested or filter out the camera with grep -v Camera-JNI.

like image 22
Nikolay Elenkov Avatar answered Nov 15 '22 19:11

Nikolay Elenkov