Opened 6 weeks ago

Last modified 4 weeks ago

#29329 assigned Cleanup/optimization

Inconsistent datetime logging from runserver.

Reported by: Sjoerd Job Postmus Owned by: Srinivas Reddy Thatiparthy
Component: Core (Other) Version: 2.0
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

In Django 1.11 and higher, the runserver logging can sometimes be inconsistent.

[16/Apr/2018 13:32:35] "GET /some/local/url HTTP/1.1" 200 7927
[2018-04-16 13:32:35,745] - Broken pipe from ('127.0.0.1', 57570)

This is because logging from WSGIRequestHandler uses server_time as calculated using BaseHTTPServer.log_date_time_string. On the other hand, WSGIServer uses logging without providing a server_time. This gets "fixed" in ServerFormatter.format using self.formatTime(record, self.datefmt), which uses a completely different format.

Currently we make this at least consistent by providing the datefmt parameter when constructing the logger, but it would be better if they were coded to be in sync (and configurable?).

(Looking into it further, it looks like we should be using %(asctime)s instead of %(server_time)s, but would be good if that were the suggested default. In https://docs.djangoproject.com/en/2.0/releases/1.10/#runserver-output-goes-through-logging we see %(server_time)s.)

Change History (2)

comment:1 Changed 6 weeks ago by Tim Graham

Component: UncategorizedCore (Other)
Triage Stage: UnreviewedAccepted
Type: UncategorizedCleanup/optimization

comment:2 Changed 4 weeks ago by Srinivas Reddy Thatiparthy

Owner: changed from nobody to Srinivas Reddy Thatiparthy
Status: newassigned
Note: See TracTickets for help on using tickets.
Back to Top