This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Nicer default logging format
Type: enhancement Stage: resolved
Components: Library (Lib) Versions:
process
Status: closed Resolution: rejected
Dependencies: Superseder:
Assigned To: Nosy List: olafvdspek, rhettinger, vinay.sajip
Priority: normal Keywords:

Created on 2021-10-31 13:55 by olafvdspek, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (5)
msg405403 - (view) Author: Olaf van der Spek (olafvdspek) * Date: 2021-10-31 13:55
The default logging format will print something like: 
WARNING:root:Hello Python!

Could it default to something like this instead?

2021-10-31 14:52:36,490 WARNING: Hello Python!

logging.basicConfig(format='%(asctime)s %(levelname)s: %(message)s')
logging.warning('Hello Python!')
msg405404 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2021-10-31 14:36
Generally, we can't change defaults after an API has been published because it immediately affects the output for people who use that default.  However in the case of logging, an argument could be made that changing the default would have less impact.
msg405412 - (view) Author: Vinay Sajip (vinay.sajip) * (Python committer) Date: 2021-10-31 17:52
> However in the case of logging, an argument could be made that changing the default would have less impact.

Except that people may have used the current basic format in, for example, unit tests, and that code could break after a change like the one proposed. The default has been intentionally kept minimal for the very simplest of needs and it is easy to override this default using e.g. basicConfig() for simple needs or e.g. dictConfig() for more elaborate needs.

For those reasons, I don't think this default should be changed.
msg405418 - (view) Author: Olaf van der Spek (olafvdspek) * Date: 2021-10-31 19:46
> Except that people may have used the current basic format in, for example, unit tests, and that code could break after a change like the one proposed.

They too could pass a format argument themselves rather then relying on the default format never changing.
msg405419 - (view) Author: Vinay Sajip (vinay.sajip) * (Python committer) Date: 2021-10-31 20:09
> They too could pass a format argument themselves rather then relying on the default format never changing.

Changes to the stdlib shouldn't require changing previously working code (sometimes months or years old) to fix breakage caused by new stdlib changes.
History
Date User Action Args
2022-04-11 14:59:51adminsetgithub: 89845
2021-10-31 20:09:01vinay.sajipsetmessages: + msg405419
2021-10-31 19:46:45olafvdspeksetmessages: + msg405418
2021-10-31 17:52:38vinay.sajipsetstatus: open -> closed
resolution: rejected
messages: + msg405412

stage: resolved
2021-10-31 17:14:20ned.deilysetnosy: + vinay.sajip
2021-10-31 14:36:37rhettingersetnosy: + rhettinger
messages: + msg405404
2021-10-31 13:55:19olafvdspekcreate