Python Cherrypy: Disable logging of requests
Asked Answered
K

3

5

I'm trying to silence the logging of http requests from CherryPy. I've tried

cherrypy.log.access_file = None

which as I understand it should remove the handler for access logging, but I can't seem to get it to work.

Kaciekacy answered 16/11, 2012 at 18:36 Comment(1)
possible duplicate of Silencing cherrypyCorroborant
L
6

Apparently, telling CherryPy to stop logging doesn't actually do anything when you've independently configured Python's logging module. The solution is to do this:

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

(Hat tip to this blog post, which is unfortunately now down.)

Lakia answered 9/12, 2014 at 21:11 Comment(0)
C
5

This is how I normally do:

    access_log = cherrypy.log.access_log
    for handler in tuple(access_log.handlers):
        access_log.removeHandler(handler)
Consumptive answered 19/12, 2013 at 10:44 Comment(0)
S
0

It says on the docs page for the latest version of CherryPy to set the handler to "" not to None

# Remove the default FileHandlers if present.
log.error_file = ""
log.access_file = ""
Swap answered 16/11, 2012 at 18:48 Comment(1)
Thanks, but that doesn't work either. On the same page you linked to, in the classes section it says that access_file can be set to either None or ''. But neither seem to work for me. Though I can turn off logging all together by setting log.screen to false.Kaciekacy

© 2022 - 2024 — McMap. All rights reserved.