13

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

Fernando Gallego
  • 4,064
  • 31
  • 50
  • This doesn't answer your question directly, but you can increase the number of lines in the LogCat buffer (Preferences --> Android-->LogCat --> Number of LogCat messages to buffer) – curioustechizen Jul 24 '12 at 10:16
  • 1
    `local.prop` file should be put in the `/data` directory (i.e. "data" directory in the root of Android filesystem), like this: `adb push local.prop /data`. But in most cases you won't be able to replace/modify that file until you root the phone. – Volo Jul 24 '12 at 10:20
  • @Idolon I rooted the phone, created a `local.prop` file with this line: `log.tag.Camera-JNI=SUPPRESS` and I pushed it to the `/data` folder but I still see the log with that tag in the logcat so I guess that the docs are wrong – Fernando Gallego Jul 24 '12 at 11:32
  • @curioustechizen yes, but then the memory consumption rises and the problem remains – Fernando Gallego Jul 24 '12 at 11:34
  • @ferdy182 Did you reboot the phone after you had created `/data/local.prop`? – Volo Jul 24 '12 at 12:51
  • @Idolon yes, I just did it after reading your comment. The log tag is still appearing in the logcat – Fernando Gallego Jul 24 '12 at 13:46
  • It looks like I am the only one who actually looked at the source. – wojciii Jul 29 '12 at 20:49

3 Answers3

7

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.

Gray
  • 115,027
  • 24
  • 293
  • 354
wojciii
  • 4,253
  • 1
  • 30
  • 39
1

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.

Nikolay Elenkov
  • 52,576
  • 10
  • 84
  • 84
  • The first one didn't work, I tried adb shell setprop log.tag.Camera-JNI SUPPRESS with no effect. The second one is just hiding the tags you don't want to see but this doesn't prevent the logcat to be filled up quickly, discarding old lines in the Eclipse Logcat Viewer when it is full – Fernando Gallego Jul 24 '12 at 09:52
  • 2
    Well, in that case, since this is not your code, you can't really do anything but: 1) complain to Samsung, or 2) install a custom ROM that doesn't do this. – Nikolay Elenkov Jul 24 '12 at 13:45
  • I'm not sure whether it is possible or not, but a third option would be to modify the [Eclipse/DDMS code](http://omapzoom.org/?p=platform/sdk.git;a=blob;f=ddms/libs/ddmuilib/src/com/android/ddmuilib/logcat/LogCatReceiver.java;hb=HEAD) so that it can filter out the undesired entries without filling up its buffer. – Joe Jul 28 '12 at 19:09
  • @JosephJudistira maybe but I have no idea how to do it – Fernando Gallego Jul 28 '12 at 21:25
0

If you want to see specific tags use:

logcat -s YourTag:* SecondTag:* ThirdTag:* ...

You can also use adb logcat

Just specify <TAG>:* as many times as you want to filter the tags you need.

Example: adb logcat -s AndroidRuntime:* MyApp:* filters AndroidRuntime and MyApp tags. So you see all uncaught exceptions (crashes) and also all logs of your application.

xdevs23
  • 3,824
  • 3
  • 20
  • 33