什么时候使用不同的日志级别? [英] When to use the different log levels?
本文介绍了什么时候使用不同的日志级别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
按照死亡的顺序记录邮件的方式有很多种:
There are different ways to log messages, in order of fatality:
-
FATAL
FATAL
错误
WARN
INFO
DEBUG
TRACE
如何决定何时使用?
什么是好的启发式使用?
What's a good heuristic to use?
推荐答案
以下约定:
- 跟踪 - 只有当我将跟踪代码并试图找到一个
- 调试 - 除了开发人员(IT,系统管理员等)之外,对诊断有帮助的信息。
- 信息 - 记录的一般有用信息(服务启动/停止,配置假设等)。信息我想永远可用,但通常在正常情况下不关心。这是我的现成的配置级别。
- 警告 - 任何可能会导致应用程序怪异,但是我自动恢复的东西。 (例如从主服务器切换到备份服务器,重试操作,缺少辅助数据等)
- 错误 - 任何对操作 ,而不是服务或应用程序(无法打开所需的文件,缺少数据等)。这些错误将强制用户(管理员或直接用户)干预。
- 致命 - 任何强制关闭服务或应用程序以防止数据丢失的错误(或在应用程序中保留)进一步的数据丢失)。我保留这些只是为了确保有数据损坏或丢失的最可怕的错误和情况。
- Trace - Only when I would be "tracing" the code and trying to find one part of a function specifically.
- Debug - Information that is diagnostically helpful to people more than just developers (IT, sysadmins, etc.).
- Info - Generally useful information to log (service start/stop, configuration assumptions, etc). Info I want to always have available but usually don't care about under normal circumstances. This is my out-of-the-box config level.
- Warn - Anything that can potentially cause application oddities, but for which I am automatically recovering. (Such as switching from a primary to backup server, retrying an operation, missing secondary data, etc.)
- Error - Any error which is fatal to the operation, but not the service or application (can't open a required file, missing data, etc.). These errors will force user (administrator, or direct user) intervention. These are usually reserved (in my apps) for incorrect connection strings, missing services, etc.
- Fatal - Any error that is forcing a shutdown of the service or application to prevent data loss (or further data loss). I reserve these only for the most heinous errors and situations where there is guaranteed to have been data corruption or loss.
这篇关于什么时候使用不同的日志级别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文