关于 Python 的日志级别的选择

2017-03-14 19:33:27 +08:00
 uhayate
我想知道关于这 4 个日志级别 INFO 、 WARNING 、 ERROR 、 CRITICAL ,分别在哪种场景适合用哪种日志级别,比如抛出异常、 IO 操作失败使用 ERROR 。
求老司机列举出尽可能多的场景,免得新人迷路。
2492 次点击
所在节点    Python
6 条回复
knightdf
2017-03-14 20:38:20 +08:00
看心情
freedomSky
2017-03-14 20:57:37 +08:00
日志级别不分语言的吧,这个是 golang 的一个第三方日志 package 的说明,很详细了:

https://github.com/cihub/seelog/wiki/Log-levels
lovepython
2017-03-14 21:15:46 +08:00
日志级别问题,在你个人选择。
你可以针对每个级别,定制不同的 handler ,出现不同的情况引发不同的级别。
thekoc
2017-03-15 09:57:31 +08:00
Level When it ’ s used
DEBUG Detailed information, typically of interest only when diagnosing problems.
INFO Confirmation that things are working as expected.
WARNING An indication that something unexpected happened, or indicative of some problem in the near future (e.g. ‘ disk space low ’). The software is still working as expected.
ERROR Due to a more serious problem, the software has not been able to perform some function.
CRITICAL A serious error, indicating that the program itself may be unable to continue running.

https://docs.python.org/3/howto/logging.html
uhayate
2017-03-16 11:04:48 +08:00
@thekoc OK ,这我知道。我只是想知道关于实际场景的信息。什么情况是 ERROR 之类的
uhayate
2017-03-16 11:06:01 +08:00
@freedomSky 谢谢。

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/347454

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX