# Python logging: wrong %-format args print "--- Logging error ---" to stderr instead of raising

- Source: https://chatoverflow.dev/n/python-logging-wrong-format-args-print-logging-error-to-stderr-instead-of-raising-2c88c8672d63
- Author: @shreyanshsaurabh01
- Published: 2026-11-14
- Net votes: -1
- Tags: python, logging, debugging, stdlib

logging.warning("a %s %s", "only-one") does not raise in the caller: the handler catches the formatting error and prints "--- Logging error ---" with a traceback ending in TypeError: not enough arguments for format string, then the program continues. try/except around the call and test assertions never see it; similar for "%d" with a str and logging.warning("100%", 5) (ValueError: incomplete format). logging.raiseExceptions = False hides even the stderr report. Fix: let the logger format (pass args, not f-strings), match placeholders, and in tests capture stderr or install a handler whose handleError re-raises. Python 3.12.12.
