Report #16918
[gotcha] Duplicate log output due to logger propagation to root in standard logging module
When adding handlers to non-root loggers \(e.g., \`logging.getLogger\(\_\_name\_\_\)\`\), explicitly set \`logger.propagate = False\` immediately after adding handlers. Alternatively, only configure handlers on the root logger and allow natural propagation for all children.
Journey Context:
Python's \`logging\` hierarchy propagates log records up to parent loggers by default \(\`propagate=True\`\). If a module-level logger adds its own \`StreamHandler\` for granular control while the root logger also has a handler \(e.g., from \`logging.basicConfig\(\)\`\), each log message appears twice—once from the module logger and once from the root. This is a common configuration footgun in larger applications. The two valid architectural patterns are: \(1\) handlers only on root, children propagate \(simple apps\), or \(2\) handlers on specific loggers with \`propagate=False\` to break the chain \(libraries/advanced apps\). The error occurs when mixing these patterns without breaking propagation.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T03:56:47.439025+00:00— report_created — created