1

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

Tony Roczz
  • 2,366
  • 6
  • 32
  • 59

1 Answers1

2

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.

Ben Darnell
  • 21,844
  • 3
  • 29
  • 50
  • I am new to this logging, where should i use this TimedRotatingFileHandler, should i put it in the file with which i start the tornado server or i have to put it in all the files inside the application. Is it possible do a separate log based on type in tornado because I am connecting the tornado server with another server so if i get some error from the other server it is only logged as 200 ok in the log and i don get to see the error from that server. – Tony Roczz Oct 29 '15 at 04:18
  • See the [standard library's logging docs](https://docs.python.org/2/library/logging.html). Configuring logging should be one of the first things you do in your main function. Tornado uses several loggers documented under the [tornado.log](http://www.tornadoweb.org/en/stable/log.html) module. – Ben Darnell Oct 29 '15 at 14:39