Joohwan
Joohwan

Reputation: 2512

Tornado: get log_message of HTTPError for logging during on_finish of request handlers?

I want to do some custom logging with Tornado.

When I throw a tornado.web.HTTPError with an error message, is there a way for me to retrieve the message for my request handler's on_finish() method? If not, how can I log it?

Thanks in advance.

Upvotes: 0

Views: 391

Answers (1)

stalk
stalk

Reputation: 12054

It is possible to override RequestHandler's write_error method:

RequestHandler.write_error(status_code, **kwargs)

You can process the exception there: log it or show custom page. The details of exception are kept in kwargs["exc_info"].

Upvotes: 1

Related Questions