Use this guide when a script or small web app runs somewhere you cannot watch it, such as a server or scheduled job, and you struggle to work out what went wrong. The examples use Python's built-in logging module, but the ideas apply to any language.
Step by step
Decide what questions logs must answer
Write down three questions you wish you could answer after a failure, such as: Which customer request failed? What input caused it? How long did the job take? Logging should answer these, not record every line the program runs. This list stops logs becoming noise that nobody reads.
The rest of this guide is for members
The rest of this guide – the remaining steps, a ready-to-use checklist, practical tips and fixes for common problems – is for members. Membership unlocks every ABCDayZ guide.
£3.99 for 1 month or £29 for 12 months. One payment, no automatic renewal.
Unlock all guidesAlready a member on another device? Open your personal access link. Bought Programming with AI? Your first month is included.