0

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?

4

1 回答 1

2

我认为你需要包装你的日志:

if (Log.isLoggable("MY_TAG", Log.VERBOSE)) {
        Log.v("MY_TAG", "Here's a log message");
}

否则android似乎会忽略您的设置;似乎Log.v, Log.d, etc.没有检查 LogLevel。

于 2015-02-03T18:21:39.183 回答