Android日志级别 [英] Android Log Levels

查看:203
本文介绍了Android日志级别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Android支持各种日志级别,包括详细,调试,信息,警告和错误.我了解日志记录级别的工作方式;我对给定级别的预期典型输出更感兴趣.

Android supports various log levels, Verbose, Debug, Info, Warn and Error. I understand how the logging levels work; I'm more interested in the typical output expected for a given level.

例如,在开发应用程序时,我可能会对某种方法正在做某事感到好奇(这通常是出于调试目的).我将仔细检查日志,以确保按预期顺序调用了这些方法,网络响应是否符合我的预期,解析器是否找到了正确的信息,等等.

For example, when developing an application I might be curious when a certain method is doing something (this often tends to be for debugging purposes). I'll look through the logs to make sure the methods are being called in an expected order, if the network response is what I think it should be, if the parsers finds the right information, etc.

为什么会有人使用Verbose vs Debug vs Info?

Why would some one use Verbose vs Debug vs Info?

从开发人员的角度来看,对于第一,第二或第三方应用程序,不是所有日志都用于调试目的吗? (假设开发人员不会盯着日志找乐子...我不是那么虐待狂)

From the perspective of a developer, for a first, second, or third party application aren't all logs for debugging purposes? (assuming devs don't stare a logs for fun... I'm not that sadistic)

从消费者的角度来看,当s ***受到打击时,他们需要联系客户支持,因为他们的超重要/业务关键型应用程序无法正常工作,开发人员将日志用于调试目的.

From the perspective of a consumer, when the s*** hits the fan and they need to contact customer support because their super important / business critical application isn't working a developer uses the log for debugging purposes.

我可以看到使用详细信息或信息的唯一原因可能是度量收集/数据仓库相关的操作.如果是这样,为什么要使用冗长vs信息.

The only reason I could see for using verbose or info is perhaps metrics gathering / data warehouse related operations. If so, why use verbose vs info.

不确定我是否过于复杂,还是android框架是...

Not sure If I'm overcomplicating this or if the android framework is...

推荐答案

我基本上遵循Tomasz Nurkiewicz

I basically follow what Tomasz Nurkiewicz has to say when considering logging level:

错误–发生了非常严重的错误,必须立即进行调查.没有系统可以容忍在此级别上记录的项目.例如:NPE,数据库不可用,关键任务用例无法继续.

ERROR – something terribly wrong had happened, that must be investigated immediately. No system can tolerate items logged on this level. Example: NPE, database unavailable, mission critical use case cannot be continued.

WARN –该过程可能会继续,但要格外小心.示例:在开发模式下运行的应用程序"或使用密码未保护管理控制台".该应用程序可以容忍警告消息,但应该始终对警告消息进行辩护和检查.

WARN – the process might be continued, but take extra caution. Example: "Application running in development mode" or "Administration console is not secured with a password". The application can tolerate warning messages, but they should always be justified and examined.

INFO –重要的业务流程已完成.在理想情况下,管理员或高级用户应该能够理解INFO消息并快速找出应用程序在做什么.例如,如果某个应用程序仅涉及机票预订,则每张机票仅应有一个INFO语句,上面写着"[谁]从[Where]到[Where]预订了机票". INFO消息的其他定义:显着改变应用程序状态的每个操作(数据库更新,外部系统请求).

INFO – Important business process has finished. In ideal world, administrator or advanced user should be able to understand INFO messages and quickly find out what the application is doing. For example if an application is all about booking airplane tickets, there should be only one INFO statement per each ticket saying "[Who] booked ticket from [Where] to [Where]". Other definition of INFO message: each action that changes the state of the application significantly (database update, external system request).

DEBUG-开发人员资料.

DEBUG – Developers stuff.

VERBOSE –非常详细的信息,仅用于开发.在生产环境上部署后,您可能会在很短的时间内保留跟踪消息,但是将这些日志语句视为临时日志,最终应该或可能将其关闭. DEBUG和VERBOSE之间的区别是最困难的,但是如果您在开发和测试功能后放入日志记录语句并将其删除,则它可能应该处于VERBOSE级别.

VERBOSE – Very detailed information, intended only for development. You might keep trace messages for a short period of time after deployment on production environment, but treat these log statements as temporary, that should or might be turned-off eventually. The distinction between DEBUG and VERBOSE is the most difficult, but if you put logging statement and remove it after the feature has been developed and tested, it should probably be on VERBOSE level.

我最喜欢的级别是WTF(2.2+),在永远都不会发生的情况下,它应该代表多么可怕的失败".

My most favorite level is WTF(2.2+) which is supposed to stand for "What a Terrible Failure", for situations that should never happen.

我通常在简单消息中使用信息".

I normally use "info" for simple messages.

这篇关于Android日志级别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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