Skip to content

Learn: Logging and Debugging

Four short tutorials that build up your working knowledge of Python's logging module and the pdb debugger. Each one is a Jupyter notebook — read it in the browser, and edit and run any code cell directly on the page.

The tutorials build on each other, so working through them in order is the fastest path. Each takes roughly fifteen to twenty minutes.

The sequence

  1. Your first log message — getting logging configured and emitting your first messages.
  2. Log levels and formattingDEBUG, INFO, WARNING, ERROR, CRITICAL, and shaping the output.
  3. Logging to files — handlers, rotation, and getting log output off stdout.
  4. Debugging with pdbbreakpoint(), stepping, inspecting state, and post-mortem debugging.

Before you start

You'll get more from these if you're already comfortable with Python functions and modules. The Functions and Error handling guides are good warm-ups.

You don't need Python installed locally — every tutorial runs in your browser. If you'd rather run them on your own machine, each notebook has a download button in the top-right corner.