Skip to content

Importing redisvl.query configures root logging to stdout #577

Closed

Description

@abrookins

Summary

Importing redisvl.query currently mutates the root logger at import time and routes logs to sys.stdout.

That breaks any process using stdout as a protocol transport, including stdio-based MCP/JSON-RPC servers.

Why this is a problem

A library import should not:

  • call logging.basicConfig(...)
  • configure the root logger
  • default logs to stdout

In this case, importing RedisVL causes unrelated application logs to appear on stdout, which corrupts stdio protocols.

Repro

import logging
import sys

logging.getLogger().handlers.clear()
logging.getLogger().setLevel(logging.WARNING)

import redisvl.query

root = logging.getLogger()
print(root.handlers)
print(root.level)
print(getattr(root.handlers[0], "stream", None) is sys.stdout)

Observed behavior

After importing redisvl.query:

  • a root StreamHandler is installed
  • the root logger level changes
  • the handler writes to sys.stdout

In our case this surfaced as stdio MCP transport failures because log lines were emitted on the same stdout stream as JSON-RPC messages.

Expected behavior

Importing RedisVL should not mutate the root logging configuration.

If RedisVL wants library logging, a safer pattern would be one of:

  • attach a handler only to RedisVL's own logger
  • use logging.NullHandler()
  • leave handler configuration entirely to the application

Also, libraries generally should not default logs to stdout.

Likely source

redisvl/utils/log.py appears to call logging.basicConfig(..., stream=sys.stdout), and redisvl/query/query.py calls get_logger(__name__) at import time.

That combination means import redisvl.query has global side effects immediately.

If useful, I can open a follow-up PR with a minimal fix.

Activity

  1. omribz156 commented on May 25, 2026

    @omribz156
    Contributor

    I checked this against current main and it looks like the import-time root logging side effect is already gone.

    Source trace:

    • redisvl/utils/log.py now only adds logging.NullHandler() to the RedisVL logger when needed.
    • That change appears to come from d992f8f / PR Avoid configuring root logger in RedisVL #445 (Avoid configuring root logger in RedisVL).

    I also reran the repro shape against import redisvl.query.query on current main:

    root_handlers []
    root_level 30
    root_stdout False
    module_handler_types ['NullHandler']
    

    So import redisvl.query no longer installs a root StreamHandler, does not change the root level, and does not route root logs to sys.stdout in the current source tree.

    This was checked with Codex assistance, with the source and repro output manually reviewed before posting.

  2. self-assigned this
    on Aug 6, 2026
  3. linked a pull request that will close this issueAvoid configuring root logger in RedisVL #445on Aug 6, 2026
  4. vishal-bala commented on Aug 6, 2026

    @vishal-bala
    Collaborator

    Seems to have been already resolved with #445

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions