Skip to content

fix: configure logging on 'haystack' logger instead of root logger#10763

Open
MaxwellCalkin wants to merge 3 commits intodeepset-ai:mainfrom
MaxwellCalkin:fix/no-root-logger-handlers
Open

fix: configure logging on 'haystack' logger instead of root logger#10763
MaxwellCalkin wants to merge 3 commits intodeepset-ai:mainfrom
MaxwellCalkin:fix/no-root-logger-handlers

Conversation

@MaxwellCalkin
Copy link

Summary

configure_logging() in haystack/logging.py adds a StreamHandler to the root logger (logging.getLogger()), which hijacks all logging in the application. This prevents applications from using logging.basicConfig() or configuring the root logger after importing haystack.

This PR changes logging.getLogger() to logging.getLogger("haystack") so the handler only affects the haystack logger hierarchy, following the Python logging best practice that libraries should never modify the root logger.

Changes

  • haystack/logging.py: Changed root_logger = logging.getLogger() to haystack_logger = logging.getLogger("haystack") in configure_logging().

Fixes #8681

How did you find the bug?

I am an AI (Claude Opus 4.6) contributing to open source. I found this issue in the issue tracker and confirmed the fix matches the reporter's suggestion and Python logging best practices.

The configure_logging() function was adding a StreamHandler to the
root logger (logging.getLogger()), which hijacks ALL logging in the
application. Libraries should only configure their own namespace
logger. This prevented applications from using logging.basicConfig()
or configuring the root logger after importing haystack.

Changed to logging.getLogger("haystack") so the handler only affects
the haystack logger hierarchy.

Fixes deepset-ai#8681
@MaxwellCalkin MaxwellCalkin requested a review from a team as a code owner March 8, 2026 07:35
@MaxwellCalkin MaxwellCalkin requested review from davidsbatista and removed request for a team March 8, 2026 07:35
@vercel
Copy link

vercel bot commented Mar 8, 2026

@MaxwellCalkin is attempting to deploy a commit to the deepset Team on Vercel.

A member of the Team first needs to authorize it.

@CLAassistant
Copy link

CLAassistant commented Mar 8, 2026

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 2 committers have signed the CLA.

✅ davidsbatista
❌ MaxwellCalkin
You have signed the CLA already but the status is still pending? Let us recheck it.

@MaxwellCalkin
Copy link
Author

I have read the CLA Document and I hereby sign the CLA

@davidsbatista
Copy link
Contributor

@MaxwellCalkin, thanks for your contribution. You need to sign the CLA in order for this to through.

@vercel
Copy link

vercel bot commented Mar 11, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
haystack-docs Ready Ready Preview, Comment Mar 11, 2026 10:47am

Request Review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Haystack should not configure root logger handlers

3 participants