How to disable Tornado logging only

1,124 views
Skip to first unread message

Michael Korbakov

unread,
Sep 16, 2011, 8:17:02 AM9/16/11
to Tornado Web Server
Hello.

I'm looking for some way to disable logging of messages like this:

2011 Sep 16 12:11:00.000 ip-10-168-191-225 <<<slon-rest>>>: 21156 -
2011-09-16 12:11:00 - INFO - "200 GET /api/slon/
0000f8597b74cab062e607d097271f78dadc (10.162.130.5) 1.16ms"

I need to remove all Tornado log message from my logging output, but
leave everything else in place. Usually I would do it by setting log
level of particular logger to ERROR or FATAL, but Tornado is using
root logger for all log messages, so I'm confused.

Thank you in advance,

-- Michael Korbakov

Ben Darnell

unread,
Sep 16, 2011, 12:55:51 PM9/16/11
to python-...@googlegroups.com
For this message, you can either subclass Application and override the log_request method, or pass a function as the log_request application setting.


For the rest of tornado's logging, you can add a filter to the root logger that looks at the LogRecord's module attribute.

-Ben

Andrew Fort

unread,
Sep 16, 2011, 12:56:20 PM9/16/11
to python-...@googlegroups.com
On Fri, Sep 16, 2011 at 5:17 AM, Michael Korbakov <rmi...@gmail.com> wrote:

This isn't quite what you want, as it's not built in and requires some
minimal refactoring, but if you want your application messages to go
to a different file, you could just build a method much like
tornado.options.enable_pretty_logging() but attach it to a new logger.
Pass this new logger object around your request handlers either as a
class attribute (e.g., in a MyRequestHandler superclass) or via
request options. If the former, "self.logger" or thereabouts becomes
your application messages log, and logging.foo() methods remain the
tornado log.

-a

Reply all
Reply to author
Forward
0 new messages