我正在使用PyCharm,并希望测试日志记录:
import logging
logging.info("This is the logging info ...")
我想这应该会打印出‘这是日志记录信息...’当我运行这个程序的时候,我把它传到了我的主机上,但是它没有。
我没有关于日志的任何其他设置或配置。日志信息的去向是什么?
发布于 2019-06-19 21:29:31
你需要配置你的记录器,给它一个输出文件和所有的东西
logging.info(msg, *args, **kwargs)
Logs a message with level INFO on the root logger. The arguments are interpreted as for debug().
更多信息可在此处找到:https://docs.python.org/3/howto/logging-cookbook.html
发布于 2019-06-19 21:35:45
根记录器的默认级别是WARNING
。您需要首先配置记录器以更改其级别。例如,
import logging
logging.basicConfig(level=logging.INFO)
logging.info("This is the logging info ...")
https://stackoverflow.com/questions/56676097
复制相似问题