Issue #685 resolved

CherryPy 3 breaks the standard logging module

Anonymous created an issue

I made an app with CherryPy 2 that used CherryPy for access logging and the standard Python logging module for app logging. I recently upgraded to CherryPy 3 and it completely broke my logging. Nothing is being logged anymore.

I have my logging setup like this:

{{{ logger = logging.getLogger() logger.setLevel(getattr(logging, loglevel)) formatter = logging.Formatter('%(asctime)s %(levelname)s: %(message)s', '%d/%b/%Y:%H:%M:%S')

if logfile == '-': handler = logging.StreamHandler() log_screen = True else: handler = logging.FileHandler(logfile, 'a+')


logger.removeHandler(logger.handlers[0]) logger.addHandler(handler) }}}

As soon as I call cherrypy.engine.start(), I get the following log:

{{{ 10/Apr/2007:13:59:06 DEBUG: [10/Apr/2007:13:59:06] HTTP Serving HTTP on }}}

No matter what I do, no more logs appear until CherryPy shuts down:

{{{ 10/Apr/2007:13:59:57 DEBUG: [10/Apr/2007:13:59:57] ENGINE CherryPy shut down }}}

What can I do to keep CP from killing my log?

Reported by

Comments (4)

  1. Robert Brewer

    Have you read the [wiki:Logging] doc? I guess I don't see how the code you posted is supposed to interface with CherryPy. Typically, you should munge the existing Logger objects rather than making your own. They are available via cherrypy.log.access_log, cherrypy.log.error_log, app.log.access_log and app.log.error_log (where app}} is what is returned from {{{tree.mount.

  2. Log in to comment