我可以在日志中删除/隐藏不必要的INFO:CONSOLE消息吗?

时间:2018-01-27 06:04:03

标签: python-2.7 logging console

我目前正在运行效果很好的代码,但我有一些东西让我烦恼,这是我终端中不必要的信息消息。

我的代码是在网站上运行的脚本,消息说"用于从https://www.paypal.com加载资源的SSL证书将来会受到不信任。一次,不信任......

没有,如果这对我很重要。有没有办法把它拿出来让我的控制台日志更清晰?

1 个答案:

答案 0 :(得分:1)

您应该将根记录器级别提升到WARNING,ERROR或CRITICAL。日志级别控制您想要查看的日志类型。警告不是错误,但可能会在应用程序中导致一些意外结果,ERROR是自我解释以及CRITICAL。

您可以为课程或包级别设置不同的级别。

The root logger must specify a level and a list of handlers. An example of a root logger section is given below.

[logger_root]
level=NOTSET
handlers=hand01
The level entry can be one of DEBUG, INFO, WARNING, ERROR, CRITICAL or NOTSET. For the root logger only, NOTSET means that all messages will be logged. Level values are eval()uated in the context of the logging package’s namespace.