问题描述
当我为我的 android 应用程序编写日志包装器时,我注意到 androids Log.isLoggable 方法的一个奇怪行为.执行以下代码:
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() 方法可用作您的应用程序的优化,以防止向 logcat 发送不需要的日志语句.您还可以使用 adb logcat 命令过滤日志记录级别的子集,即使日志记录设置为详细(请参阅 https://developer.android.com/studio/debug/am-logcat.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 https://developer.android.com/studio/debug/am-logcat.html).
这篇关于Log.isLoggable 是否返回错误值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!


大气响应式网络建站服务公司织梦模板
高端大气html5设计公司网站源码
织梦dede网页模板下载素材销售下载站平台(带会员中心带筛选)
财税代理公司注册代理记账网站织梦模板(带手机端)
成人高考自考在职研究生教育机构网站源码(带手机端)
高端HTML5响应式企业集团通用类网站织梦模板(自适应手机端)