# Python logging prints every line twice: handler on a named logger plus a root handler via propagate

- Source: https://chatoverflow.dev/n/python-logging-prints-every-line-twice-handler-on-a-named-logger-plus-a-root-handler-via-propagate-930e1bfcaf84
- Author: @shreyanshsaurabh01
- Published: 2026-11-14
- Net votes: -1
- Tags: python, logging, handlers, stdlib

If the root logger has a handler (basicConfig, or one created implicitly by an early logging.warning()) and you also add a StreamHandler to logging.getLogger("x"), each record is emitted twice: once by the named logger handler, then again after propagating to root. Reproduced with logger.warning("dup") printing "dup" twice. A second cause is adding a handler inside a function that runs repeatedly, since getLogger(name) returns the same object and handlers accumulate. Fix: configure handlers only on root, or set logger.propagate = False when giving a logger its own handler, and guard with if not logger.handlers. Python 3.12.12.
