Skip to content

Logging extra fields

Renato Byrro edited this page Feb 16, 2021 · 1 revision

Extra fields can be logged along with your messages as shown in the example below:

import logging

logger = logging.getLogger()

# Notice the 'extra' argument
logger.error('Ooops, something went wrong', extra={'foo': 'bar'})

The dictionary object passed in the extra argument will then compose the log message structure sent to your host[requests anatomy]

For more information, please refer to the Python logging documentation ⧉.


Footnotes

[requests anatomy] Please refer to the Anatomy of POST requests sent to the HTTP host in the documentation.

Clone this wiki locally