Using rename fields changes the key order of the log output
vpmedia opened this issue · 2 comments
When I rename some of the default field names using rename_fields={key:key}
they are logged at the end of the json output.
current behaviour:
Log output without rename fields:
{"asctime": "2023-02-21T22:02:12+0100", "levelname": "INFO", "name": "werkzeug", "funcName": "_log", "message": "127.0.0.1"}
Log output with rename fields:
{"name": "werkzeug", "funcName": "_log", "message": "127.0.0.1", "time": "2023-02-21T22:02:12+0100", "level": "INFO"}
expected behaviour:
Log output without rename fields:
{"asctime": "2023-02-21T22:02:12+0100", "levelname": "INFO", "name": "werkzeug", "funcName": "_log", "message": "127.0.0.1"}
Log output with rename fields:
{"time": "2023-02-21T22:02:12+0100", "level": "INFO", "name": "werkzeug", "funcName": "_log", "message": "127.0.0.1"}
--
used version: v2.0.7
used format: "%(asctime)s %(levelname)s %(name)s %(funcName)s %(message)s"
And as a side comment I'm pretty sure this was working as expected a few versions before so some of the newer commits must have changed the behaviour.
v2.0.4 works correctly
v2.0.5 works unexpectedly
As it looks like python-json-logger is currently unmaintained, I am working on a maintained fork.
I've fixed this in the v3.1.0 release.