Search code examples
pythontornado

Where can I check tornado's log file?


I think there was a default log file, but I didn't find it yet.

Sometimes the HTTP request process would throw an exception on the screen, but I suggest it also goes somewhere on the disk or I wouldn't know what was wrong during a long run test.

P.S.: write an exception handler is another topic; first I'd like to know my question's answer.

I found something here: https://groups.google.com/forum/?fromgroups=#!topic/python-tornado/px4R8Tkfa9c

But it also didn't mention where can I find those log.


Solution

  • It uses standard python logging module by default.

    Here is definition:

    access_log = logging.getLogger("tornado.access")
    app_log = logging.getLogger("tornado.application")
    gen_log = logging.getLogger("tornado.general")
    

    It doesn't write to files by default. You can run it using supervisord and define in supervisord config, where log files will be located. It will capture output of tornado and write it to files.

    Also you can think this way:

    tornado.options.options['log_file_prefix'].set('/opt/logs/my_app.log')
    tornado.options.parse_command_line()
    

    But in this case - measure performance. I don't suggest you to write to files directly from tornado application, if it can be delegated.

    FYI: parse_command_line just enables pretty console logging.