logging

Python's built-in way to record what a program does, with levels from DEBUG to CRITICAL.

Also called: log level, print debugging

Source
General
Language
Python

In plain English

Better than print for anything that runs unattended: timestamps, levels, and output to files.

Example

The importer logs a warning for every row without an email.

In code

import logging
logging.basicConfig(level=logging.INFO, format="%(asctime)s %(levelname)s %(message)s")
log = logging.getLogger("importer")
log.info("Imported %d rows", n)

Related terms

Added 2026-11-30 · Last reviewed 2026-11-30