Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add mechanism to override INFO level request logging #20

Closed
timcnicholls opened this issue Nov 21, 2016 · 1 comment
Closed

Add mechanism to override INFO level request logging #20

timcnicholls opened this issue Nov 21, 2016 · 1 comment
Assignees

Comments

@timcnicholls
Copy link
Collaborator

With logging levels set to INFO or higher, tornado logs an INFO message (to stderr by default) for every request, rapidly filling logfiles. This can be modified by overriding the settings to the tornado.access logger, or following the instructions in tornado/web.py method log_request:

@timcnicholls
Copy link
Collaborator Author

def log_request(self, handler):
        """Writes a completed HTTP request to the logs.

        By default writes to the python root logger.  To change
        this behavior either subclass Application and override this method,
        or pass a function in the application settings dictionary as
        ``log_function``.
        """
        if "log_function" in self.settings:
            self.settings["log_function"](handler)
            return
        if handler.get_status() < 400:
            log_method = access_log.info
        elif handler.get_status() < 500:
            log_method = access_log.warning
        else:
            log_method = access_log.error
        request_time = 1000.0 * handler.request.request_time()
        log_method("%d %s %.2fms", handler.get_status(),
                   handler._request_summary(), request_time)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant