python-json-logger icon indicating copy to clipboard operation
python-json-logger copied to clipboard

Using rename fields changes the key order of the log output

Open vpmedia opened this issue 2 years ago • 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"

vpmedia avatar Feb 21 '23 21:02 vpmedia

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

vpmedia avatar Feb 22 '23 07:02 vpmedia

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.

nhairs avatar May 28 '24 09:05 nhairs