Interview Prep/Python for DevOps/Runtime, file, subprocess & encoding errors

Logs appear twice for every message after you added a handler.

IntermediateTroubleshootingRuntime, file, subprocess & encoding errors
Answer

Likely causes → A handler was added to your named logger and the root logger also has one, so records propagate and are emitted twice; or basicConfig/addHandler runs on every function call or import.

Diagnose →

print(logging.getLogger("cloudaudit").handlers, logging.getLogger().handlers)

Fix → Configure handlers once, on the root logger only, in the entry point; or set propagate = False on the logger that has its own handler.

Prevent → Modules only call getLogger(__name__); only main() configures.

All Python for DevOps questions Roadmap: Python for automation

More on Runtime, file, subprocess & encoding errors