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.

1

3 Answers 3

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.)

5

This is how I normally do:

    access_log = cherrypy.log.access_log
    for handler in tuple(access_log.handlers):
        access_log.removeHandler(handler)
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 = ""
1
  • 4
    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.
    – Ben Davis
    Nov 16, 2012 at 19:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.