Prevent cherrypy from logging access
Question: I'm trying to set up a logger to only catch my ERROR level messages, but my
logger always seems to write `INFO:cherrypy.access` messages to my log file,
which I dont want. I tried setting the `log.error_file` global, and using the
standard python logging module `logging.basicConfig(filename='error.log',
filemode='w', level=logging.ERROR)`, but even though I specify the threshold
to be ERROR level messages, I still get those INFO level messages written to
my log file. Is there any way to prevent this?


Answer: Seems like the `INFO` level logs are coming for `cherrypy.access` . According
to
[documentation](https://cherrypy.readthedocs.org/en/3.3.0/refman/_cplogging.html)
-

> You should set these at either the global level or per application (see
> next), but generally not both.
>
> **log.screen** : Set this to True to have both “error” and “access” messages
> printed to stdout. **log.access_file** : Set this to an absolute filename
> where you want “access” messages written. **log.error_file** : Set this to
> an absolute filename where you want “error” messages written.

You should also try setting the `log.access_file` (similar to
`log.error_file`) . Or you can add an handler for that, example -

    
    
    from logging import handlers
    fname = getattr(log, "rot_access_file", "access.log") #The log for access messsages.
    h = handlers.TimedRotatingFileHandler(fname, when='midnight')
    h.setLevel(logging.DEBUG)
    h.setFormatter(_cplogging.logfmt)
    log.access_file = ""
    log.access_log.addHandler(h)
    

