如何禁用 logging在 Python 中的标准错误流上?这不起作用:
import logging
logger = logging.getLogger()
logger.removeHandler(sys.stderr)
logger.warning('foobar') # emits 'foobar' on sys.stderr
最佳答案
我找到了解决方案:
logger = logging.getLogger('my-logger')
logger.propagate = False
# now if you use logger it will not log to console.
这将阻止将日志记录发送到包含控制台日志记录的上层记录器。
关于python - 如何禁用标准错误流的日志记录?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2266646/