Django: Adding a Custom Attribute to All Log Lines

Django provides logging out of the box, and gives us the tools to customize what gets logged how.

This is not an in-depth primer on logging with Django— I’ve linked to the relevant documentation for the different pieces discussed here, but this is more an end-to-end implementation than a deep-dive — we’re going to look at how to add a custom attribute to all of our log lines. For example, if we have a multi-tenant application, we may want to know which organization performed each action for which there is a log line. So let’s implement this…