-
Notifications
You must be signed in to change notification settings - Fork 574
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug] Parameters not in order #155
Comments
The json out is ordered as written in the code. The ConsoleWriter does not keep this order because it does umarshaling of the json to format it. |
Hi @rs thank you for the fast response. There is any workaround to force an specific order also with ConsoleWriter? |
We would need to change the way the json is unmarshaled. Possible but requires a patch. |
Hi I came across this issue and I think maybe we can add a function in |
Hi @TommyCpp this sounds great! |
Ordering by the JSON keys is important as it allows one to more easily parse/read through the logs since fields are in the same order. Having random ordering of the key-values make it hard to read when going through logs. If your only goal is to load into an ELK stack or similar then ordering may not matter as much. However, developers often need to be able to read log files locally and this makes a huge difference. Having ordering as an option that can be enabled/disabled would still allow for the increased speed where folks don't care, and the negligible slowdown when they do. |
I completely agree with your point of view. Formatted logs can help developers, testers, and operations personnel quickly read them without the need for complex searching and eye scanning. |
Just submitted PR #550. |
Any chance for this to get merged? |
I think it's hard/impossible to fix completely on top of stdlib, that's why I develop a home made json parser based on gjson to output text fields same as logging statement. https://github.com/phuslu/log/blob/master/formatter.go |
Hi We are working with zerolog to create a kind of HTTP access.log and as mentioned here #50 (comment) I need the order I use in the code.
Here the code.
https://github.com/toni-moreno/influxdb-srelay/blob/0e7f56f7c6e3f626773fa17d88b33ad20b453fda/relay/http_middlewares.go#L69-L84
And here the output with the consolewritter
As you can see there is no order in the output
The text was updated successfully, but these errors were encountered: