Opened 8 years ago
Closed 6 years ago
#29329 closed Cleanup/optimization (fixed)
Inconsistent datetime logging from runserver.
| Reported by: | Sjoerd Job Postmus | Owned by: | Hasan Ramezani |
|---|---|---|---|
| Component: | Core (Other) | Version: | 2.0 |
| Severity: | Normal | Keywords: | |
| Cc: | Triage Stage: | Accepted | |
| Has patch: | yes | 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 (6)
comment:1 by , 8 years ago
| Component: | Uncategorized → Core (Other) |
|---|---|
| Triage Stage: | Unreviewed → Accepted |
| Type: | Uncategorized → Cleanup/optimization |
comment:2 by , 8 years ago
| Owner: | changed from to |
|---|---|
| Status: | new → assigned |
comment:3 by , 6 years ago
| Has patch: | set |
|---|---|
| Owner: | changed from to |
comment:4 by , 6 years ago
| Patch needs improvement: | set |
|---|
comment:5 by , 6 years ago
| Patch needs improvement: | unset |
|---|