[New-bugs-announce] [issue33400] logging.Formatter does not default to ISO8601 date format

Paul Cyr report at bugs.python.org
Tue May 1 15:37:24 EDT 2018


New submission from Paul Cyr <python at paulcyr.ca>:

>From the docs:

https://docs.python.org/3.6/library/logging.html#logging.Formatter

"class logging.Formatter(fmt=None, datefmt=None, style='%') ...
If no datefmt is specified, the ISO8601 date format is used."

However, the output from the formatter when no datefmt is specified is not an ISO8601 date. It is also a datetime format, not a date format.

Example output: 2018-05-01 19:04:31,505

Not being an ISO member, I don't have access to the official source for the specification but, trusting other sources, it appears that the output is missing the required 'T' delimiter between the date and time, and it is also missing the timezone. A compliant output would be:

2018-05-01T19:04:31,505Z

The current output appears to actually be closer to RFC 3339, as that standards allows for a space instead of the 'T' delimiter, but RFC 3339 still requires a timezone.

Either the documentation should be updated to state that the format used is an RFC 3339 datetime but without a timezone, or the format should comply with the standard specified in the documentation.

----------
components: Library (Lib)
messages: 316012
nosy: paulc
priority: normal
severity: normal
status: open
title: logging.Formatter does not default to ISO8601 date format
type: behavior
versions: Python 3.4

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue33400>
_______________________________________


More information about the New-bugs-announce mailing list