Python Cherrypy:禁用请求记录

时间:2012-11-16 18:36:40

标签: python cherrypy

我正试图阻止来自CherryPy的http请求的记录。我试过了

cherrypy.log.access_file = None

根据我的理解,它应该删除访问日志记录的处理程序,但我似乎无法让它工作。

3 个答案:

答案 0 :(得分:5)

显然,当你独立配置Python的logging模块时,告诉CherryPy停止记录实际上并没有做任何事情。解决方案是这样做:

cherrypy.log.error_log.propagate = False
cherrypy.log.access_log.propagate = False

(帽子提示this blog post,不幸的是现在已经失败了。)

答案 1 :(得分:4)

这就是我通常做的事情:

    access_log = cherrypy.log.access_log
    for handler in tuple(access_log.handlers):
        access_log.removeHandler(handler)

答案 2 :(得分:0)

在最新版本的CherryPy的docs page上说,将处理程序设置为""而不是None

# Remove the default FileHandlers if present.
log.error_file = ""
log.access_file = ""