all Python 3loggingfunction
logging.debug()
levels
Writes a message at the DEBUG level — the lowest one. Use it for detailed diagnostics during development. Usually switched off in production.
Syntax
logging.debug(msg, *args, **kwargs)
The usual stumble is calling logging.debug() and seeing nothing at all: the root logger's default threshold is WARNING, so DEBUG records are dropped until you call basicConfig(level=logging.DEBUG) — and it must come before the first logging call, since basicConfig() silently does nothing once the logger is configured. Arguments are interpolated lazily, only when the record is actually emitted, so pass them as %s/%r placeholders instead of building an f-string: with DEBUG off the formatting never runs.
Examples
import logging
logging.basicConfig(level=logging.DEBUG)
logging.debug('Переменная x = %s', 42)
logging.debug('Входные данные: %r', [1, 2, 3])
See also
Open in the full glossarydocs.python.orgReport an inaccuracy