Skip to content

Commit 8efaa45

Browse files
authored
fix(logging): route uvicorn logs through the JSON pipeline (#51)
PR #48 ("Splunk-friendly JSON logs") missed that uvicorn attaches its own plaintext StreamHandlers to the `uvicorn` / `uvicorn.error` / `uvicorn.access` loggers with `propagate=False`. Result: app logs are JSON but uvicorn boot lines ("Started server process", "Application startup complete", "Uvicorn running on …") stay as `INFO:` plain text, fragmenting Splunk parsing. Strip those handlers and re-enable propagation so every uvicorn record flows through the root JSON handler. This is the same one-liner noergler already carries in app/logging_config.py:90-93 (PR #124).
1 parent 8eeeb5a commit 8efaa45

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

src/riptide_collector/logging_config.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,16 @@ def configure_logging(level: str = "INFO", env: str = "dev") -> None:
7777
root.handlers = [handler]
7878
root.setLevel(log_level)
7979

80+
# uvicorn attaches its own StreamHandlers to 'uvicorn' / 'uvicorn.error' /
81+
# 'uvicorn.access' with propagate=False, which means startup lines like
82+
# "INFO: Started server process" never hit our root JSON handler.
83+
# Strip those handlers and re-enable propagation so every uvicorn log
84+
# flows through the JSON pipeline.
85+
for name in ("uvicorn", "uvicorn.error", "uvicorn.access"):
86+
uv_logger = logging.getLogger(name)
87+
uv_logger.handlers = []
88+
uv_logger.propagate = True
89+
8090
# uvicorn's access log becomes redundant once our middleware emits
8191
# http_request; keep only warnings/errors from it.
8292
logging.getLogger("uvicorn.access").setLevel(logging.WARNING)

0 commit comments

Comments
 (0)