是否Log.isLoggable返回错误的值? [英] Does Log.isLoggable returns wrong values?

查看:209
本文介绍了是否Log.isLoggable返回错误的值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我在写日志包装我的Andr​​oid应用程序,我发现机器人的一个奇怪的行为Log.isLoggable方法。执行以下code:

When I was writing a log wrapper for my android application I noticed a strange behavior of androids Log.isLoggable method. Executing following code:

final String TAG = "Test";
Log.v(TAG, "verbose is active: " + Log.isLoggable(TAG, Log.VERBOSE));
Log.d(TAG, "debug is active: " + Log.isLoggable(TAG, Log.DEBUG));
Log.i(TAG, "info is active: " + Log.isLoggable(TAG, Log.INFO));
Log.w(TAG, "warn is active: " + Log.isLoggable(TAG, Log.WARN));
Log.e(TAG, "error is active: " + Log.isLoggable(TAG, Log.ERROR));

产生以下LogCat中输出:

produces following LogCat output:

VERBOSE/Test(598): verbose is active: false
DEBUG/Test(598): debug is active: false
INFO/Test(598): info is active: true
WARN/Test(598): warn is active: true
ERROR/Test(598): error is active: true

为什么我收到详细的调试是不活跃,虽然我产生这些输出使用详细和调试日志记录?

Why do I get verbose and debug is not active although I produce these outputs using verbose and debug logging?

推荐答案

所有日志级别写入的logcat无论当前日志级别是什么。该isLogabble()方法可以作为您的应用程序,以prevent发送不需要的日志语句logcat的优化。您也可以使用亚行logcat命令过滤日志记录级别的一个子集,即使日志记录设置为详细(见<一href="http://developer.android.com/guide/developing/debugging/debugging-log.html">http://developer.android.com/guide/developing/debugging/debugging-log.html).

All log levels are written to logcat regardless of what the current log level is. The isLogabble() method can be used as an optimization for your apps to prevent sending unneeded log statements to logcat. You can also use the adb logcat command to filter a subset of the logging levels even if the logging is set to verbose (see http://developer.android.com/guide/developing/debugging/debugging-log.html).

这篇关于是否Log.isLoggable返回错误的值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆