Programming guide

Add useful logging to a small application

Replace scattered print statements with structured logs at the right levels, so you can diagnose problems in a live app without leaking personal data.

Estimated time: 45–90 minutesUpdated: 1 October 2026

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

  1. 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.

Members

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 guides

Already a member on another device? Open your personal access link. Bought Programming with AI? Your first month is included.