'Logging an additional field in JSON logs in Python logging
I am trying to log an extra object in the logs of my app.
For the logger, I have an additional formatting structure, for example something similar:
{"version":"1.0","application":"app" ... etc}
then I am adding this formatter to my StreamHandler and as an output I always get those fields.
I tried with the "extra" keyword with doing something like:
log.info('this is an example log with a field', extra={'field':'value'})
but nothing happens I tried also adding the 'field' to the formatter string, but actually i don't know how to tell the logger to log the field if it appears in the logs.
i really want to loga body_dict object inside of this extra field and to query it later via Elastic.
Could anyone help?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
