Before I did any changes, I printed Log.isLoggable(MYAPP_TAG)
for all levels.
I/System.out﹕ MYAPP Loggable Level: [V:false][D:false][I:true][W:true][E:true]
And then I did adb shell setprop log.tag.MYAPP_TAG WARN
.
The Log.isLoggable(MYAPP_TAG)
message now became
I/System.out﹕ MYAPP Loggable Level: [V:false][D:false][I:false][W:true][E:true]
However, all log messages (Log.v
, Log.d
, etc) can still be observed in Logcat.
02-03 13:18:28.050 3284-3284/com.XX V/MYAPP_TAG﹕ onServiceConnected
02-03 13:18:28.050 3284-3284/com.XX D/MYAPP_TAG﹕ onServiceConnected
Why is that?
I think you need to wrap your logs:
if (Log.isLoggable("MY_TAG", Log.VERBOSE)) {
Log.v("MY_TAG", "Here's a log message");
}
otherwise android seems to ignore your settings; it seems like the Log.v, Log.d, etc.
are not checking against the LogLevel.