禁用博托记录,而无需修改博托文件文件

2023-09-11 10:18:30 作者:何必讨好

我现在用的是宝途库交谈AWS。我想禁用日志记录。 (或重定向到/ dev / null或其他文件)。我无法找到一个明显的方法来做到这一点。我想这一点,但似乎并没有帮助。

I am using the Boto library to talk to AWS. I want to disable logging. (Or redirect to /dev/null or other file). I cant find an obvious way to do this. I tried this, but that doesn't seem to help.

import boto
boto.set_file_logger('boto', 'logs/boto.log')

本说,这是可能的,http://developer.amazonwebservices.com/connect/thread.jspa?messageID=52727&#52727但AFAIK文档犯规告知如何。

This says it is possible, http://developer.amazonwebservices.com/connect/thread.jspa?messageID=52727&#52727 but AFAIK the documentation doesnt tell how.

推荐答案

您可以尝试

import logging
logging.getLogger('boto').setLevel(logging.CRITICAL)

这将坐席preSS错误的所有(除其他关键)。

which will suppress all (other than CRITICAL) errors.

博托使用日志记录配置文件(如 /etc/boto.cfg 〜/ .boto )等等看如果你可以将其配置为您的需求的方式。

Boto uses logging configuration files (e.g. /etc/boto.cfg, ~/.boto) so see if you can configure it to your needs that way.

set_file_logger 通话只是增加了一个用户自定义的文件,日志设置,所以你不能用它来关闭日志记录。

The set_file_logger call simply adds a user-defined file to the logging setup, so you can't use that to turn logging off.