JSON output lacking msg
Closed this issue · 11 comments
I am having difficulty getting the msg
of the original log to show up in the output JSON. Thinking it was something with my application I tested on the Flask example.
Here is that output:
{"line_no": 21, "correlation_id": "de3ea4b2-cced-11e8-889f-185e0fcd0c85", "component_instance": 0, "written_at": "2018-10-11T00:37:44.276Z", "component_id": "-", "written_ts": 1539218264276132000, "thread": "Thread-1", "level": "INFO", "logger": "test logger", "type": "log", "component_name": "-"}
{"line_no": 22, "correlation_id": "de3ea4b2-cced-11e8-889f-185e0fcd0c85", "extra_property": "extra_value", "component_instance": 0, "written_at": "2018-10-11T00:37:44.276Z", "component_id": "-", "written_ts": 1539218264276446000, "thread": "Thread-1", "level": "INFO", "logger": "test logger", "type": "log", "component_name": "-"}
{"protocol": "HTTP/1.1", "correlation_id": "de3ea4b2-cced-11e8-889f-185e0fcd0c85", "component_instance": 0, "written_at": "2018-10-11T00:37:44.276Z", "x_forwarded_for": "-", "remote_user": "-", "written_ts": 1539218264276673000, "request_received_at": "2018-10-11T00:37:44.276Z", "remote_port": 46268, "response_status": 200, "request_size_b": -1, "type": "request", "method": "GET", "response_time_ms": 0, "remote_ip": "127.0.0.1", "response_sent_at": "2018-10-11T00:37:44.276Z", "referer": "-", "component_id": "-", "response_size_b": 11, "request": "/", "response_content_type": "text/html; charset=utf-8", "component_name": "-", "remote_host": "127.0.0.1"}
What I am expecting is to see is the first two JSON output to have a msg
="test log statement".
will take a look
So after pulling my hair out trying to figure out why I am missing that msg
field, it is because I am using an outdated version :D :D
Do you happen to know when you'll push 0.0.7 to pypi?
A pip freeze
shows this lib to be at 0.0.1:
$ pip freeze
Click==7.0
Flask==1.0.2
itsdangerous==0.24
Jinja2==2.10
json-logging==0.0.1
MarkupSafe==1.0
Werkzeug==0.14.1
what do you mean outdated by the way?
this only has one version 0.0.1 at the moment.
The 0.0.1 version is missing an important PR, https://github.com/thangbn/json-logging-python/pull/2/files. Without it all the logs don't have the msg
field. If I pip install from master of this repo I get the msg
field back.
{"line_no": 21, "correlation_id": "de23ab64-ccf0-11e8-889f-185e0fcd0c85", "component_instance": 0, "written_at": "2018-10-11T00:59:12.589Z", "component_id": "-", "written_ts": 1539219552589550000, "thread": "Thread-1", "level": "INFO", "msg": "test log statement", "logger": "test logger", "type": "log", "component_name": "-"}
{"line_no": 22, "correlation_id": "de23ab64-ccf0-11e8-889f-185e0fcd0c85", "extra_property": "extra_value", "component_instance": 0, "written_at": "2018-10-11T00:59:12.589Z", "component_id": "-", "written_ts": 1539219552589869000, "thread": "Thread-1", "level": "INFO", "msg": "test log statement", "logger": "test logger", "type": "log", "component_name": "-"}
I guess the more correct way to say is the unreleased (0.0.7) has PR#2 that fixes logging for use with flask.
oh ok, good catch, thanks, will do today
Appreciate it!!
np, if you find this repo useful, give this repo a star 😃
released it here: https://pypi.org/project/json-logging/0.0.8/
Thanks! I gave a star!