Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python Cherrypy: Disable logging of requests

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.

like image 551
Ben Davis Avatar asked Dec 21 '22 13:12

Ben Davis


2 Answers

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

like image 84
nitwit Avatar answered Jan 03 '23 12:01

nitwit


This is how I normally do:

    access_log = cherrypy.log.access_log
    for handler in tuple(access_log.handlers):
        access_log.removeHandler(handler)
like image 28
lbolla Avatar answered Jan 03 '23 12:01

lbolla