logging.info不会显示在控制台上,但会发出警告和错误提示 [英] logging.info doesn't show up on console but warn and error do
本文介绍了logging.info不会显示在控制台上,但会发出警告和错误提示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我使用logging.info
记录事件时,该事件不会出现在Python终端中.
When I log an event with logging.info
, it doesn't appear in the Python terminal.
import logging
logging.info('I am info') # no output
相反,用logging.warn
记录的事件确实出现在终端中.
In contrast, events logged with logging.warn
do appear in the terminal.
import logging
logging.warn('I am warning') # outputs "I am warning"
是否可以更改环境级别以将logging.info
打印到控制台?我想避免在每个Python文件中进行更改.
Is there a environment level change I can to make logging.info
print to the console? I want to avoid making changes in each Python file.
推荐答案
root logger始终默认为WARNING级别.尝试致电
The root logger always defaults to WARNING level. Try calling
logging.getLogger().setLevel(logging.INFO)
你应该没事.
这篇关于logging.info不会显示在控制台上,但会发出警告和错误提示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文