views:

286

answers:

3

If I want the access log for Cherrypy to only get to a fixed size, how would I go about using rotating log files?

I've already tried http://www.cherrypy.org/wiki/Logging, which seems out of date, or has information missing.

+2  A: 

Look at http://docs.python.org/library/logging.html.

You probably want to configure a RotatingFileHandler

http://docs.python.org/library/logging.html#rotatingfilehandler

S.Lott
A: 

Cherrypy does its logging using the standard Python logging module. You will need to change it to use a RotatingFileHandler. This handler will take care of everything for you including rotating the log when it reaches a set maximum size.

Michael Dillon
+1  A: 

I've already tried http://www.cherrypy.org/wiki/Logging, which seems out of date, or has information missing.

Try adding:

import logging
import logging.handlers
import cherrypy # you might have imported this already

and instead of

log = app.log

maybe try

log = cherrypy.log
e1i45