Skip to content

Importing redisvl.query configures root logging to stdout #577

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.

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