4

我正在尝试使来自 CherryPy 的 http 请求的日志记录静音。我试过了

cherrypy.log.access_file = None

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

4

3 回答 3

6

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

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

此博客文章的提示,不幸的是现在已关闭。)

于 2014-12-09T21:11:11.677 回答
5

这是我通常的做法:

    access_log = cherrypy.log.access_log
    for handler in tuple(access_log.handlers):
        access_log.removeHandler(handler)
于 2013-12-19T10:44:10.043 回答
0

它在最新版本的 CherryPy的文档页面""上说将处理程序设置为不None

# Remove the default FileHandlers if present.
log.error_file = ""
log.access_file = ""
于 2012-11-16T18:48:23.130 回答