Pycon Sweden 2024

Log and explore everything in Django
2024-11-15 , Tutorial 1

While there are a multitude of platforms to collect logs and metrics from "any platform", sometimes all you want is to collect the logs you need, in the format you want, and pass it on or store it without adding third party libraries, servers, and accounts. Sometimes, you may even want to write the next great log aggregation tool, not use an existing. This talk is about utilising a few different methods to create, enrich, and store log and audit data using only what comes in the box with a new Django project, and end up with rich, explorable log and audit data.


Any system with lots of users and complexity will need good logs for troubleshooting and a lot of systems will also need it for audit purposes. Adding more context and structure to logs allow it to be used for more - such as metrics - and allowing it to be explorable in relation to live data can make logs into a powerful tool for customer support and post incident investigations alike.

In this session, we'll explore several techniques to create usable data and expose it for exploration whether it's for audit trails or just a structured way to investigate the data behind the scenes. We'll contrast different ways of achieving the same goals, to give an overview of the trade-offs involved when rolling your own.

To follow the exercises, you will need Python 3.10 and git installed - for one of the exercises, Docker is needed (for running elasticsearch). All exercises except for one can also run at pythonanywhere.com. Code and slides will be available at https://github.com/metallapan/django-logging-tutorial. (Final final version no later than five minutes before the start of the session).

Fredrik is a software developing freelancer, and in 20ish years has worked in “all of the industries” in almost every role from tech lead to tester. In his career he has worked with everything from tiny startups to huge enterprise companies and he’s currently the Django lead at Codepath.

Refusing to overly specialize or ever (again) accepting a management role, he combines a long and broad experience in software development with both technical and organizational skills. Recent work has focused on building teams, securing data and processes, and making sure that things go faster and/or cheaper. Once upon a time, he instigated a conference. He is lazy by nature, which is why he automates things obsessively.