Search code examples
python-2.7loggingtornadolog-rotation

Tornado log rotation for each day


I am trying to log the requests to my tornado server to separate file, and I want to make a log rotation for each day. I want to use the tornado.log function and not the python logging.

I have defined the log path in my main class and it is logging properly I want to know if I can do a log rotate.

Does tornado log allow us to log things based on type like log4j

Thanks


Solution

  • Tornado's logging just uses the python logging module directly; it's not a separate system. Tornado defines some command-line flags to configure logging in simple ways, but if you want anything else you can do it directly with the logging module. A timed rotation mode is being added in Tornado 4.3 (--log-rotate-mode=time), and until then you can use logging.handlers.TimedRotatingFileHandler.