Skip to content

Category-specific log levels not applied to early-initialized loggers #4252

@derekhiggins

Description

@derekhiggins

Summary

Category-specific log levels configured via LLAMA_STACK_LOGGING environment variable are not applied to loggers that are created before setup_logging() is called.

Impact

When debugging specific categories (e.g., core=debug), log messages from modules imported early in the initialization process don't respect the configured log level and remain at the default level.

Reproduction Steps

  1. Set the environment variable:
export LLAMA_STACK_LOGGING=core=debug
  1. Start the llama-stack server

  2. Observe that the DEBUG level log message from src/llama_stack/core/stack.py:488 is not displayed:

logger.debug("refreshing registry")

Expected Behavior

All loggers with category="core" should log at DEBUG level when LLAMA_STACK_LOGGING=core=debug is set, regardless of when the logger was initialized.

Actual Behavior

Loggers created before setup_logging() is called (e.g., in stack.py imported at server startup) do not respect category-specific log levels and remain at the default log level.

Root Cause

Loggers are created via get_logger() at module import time before setup_logging() is called. The existing implementation in setup_logging() only applies the root level to pre-existing llama_stack loggers, ignoring their individual category assignments stored in _category_levels.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions