Files
open-webui/backend/open_webui/utils
Andrei Efanov 9e81e1dda1 feat: add LOG_FORMAT=json for structured JSON logging (#21747)
* feat: add LOG_FORMAT env var with JSON formatter for early logging

Introduce LOG_FORMAT environment variable (set to "json" to enable).
When active, logging.basicConfig() uses a JSONFormatter that outputs
single-line JSON objects with fields: ts, level, msg, caller, error,
stacktrace. This covers all log messages emitted during module imports
before Loguru's start_logger() takes over.

* feat: add JSON sink for Loguru when LOG_FORMAT=json

Add _json_sink() as a Loguru sink function that writes single-line JSON
to stdout. In start_logger(), conditionally use the JSON sink instead of
the plain-text stdout_format when LOG_FORMAT is set to "json".

* feat: suppress ASCII banner and fix alembic logging in JSON mode

- Wrap the ASCII art banner print in main.py with a LOG_FORMAT != "json"
  guard so JSON output stays machine-parseable.
- Skip alembic's fileConfig() call in migrations/env.py when
  LOG_FORMAT=json to prevent it from replacing the JSON log handlers
  installed during early startup.
2026-02-22 17:40:17 -06:00
..
2026-02-11 16:24:11 -06:00
2026-02-11 16:24:11 -06:00
2026-02-11 16:40:40 -06:00
2026-02-21 15:35:34 -06:00
2026-02-11 16:24:11 -06:00
2026-02-19 16:29:19 -06:00
2026-02-16 15:32:28 -06:00
2026-02-11 16:24:11 -06:00
2026-02-11 16:24:11 -06:00
2026-01-28 01:18:39 +04:00
2025-12-29 00:21:18 +04:00
2026-02-06 03:23:37 +04:00
2026-02-21 15:35:34 -06:00
2026-02-21 15:35:34 -06:00
2026-02-22 17:11:50 -06:00
2026-02-21 15:35:34 -06:00
2025-12-02 03:52:38 -05:00
2026-02-11 16:24:11 -06:00
2026-02-11 16:24:11 -06:00
2026-02-21 15:35:34 -06:00
2026-02-11 16:24:11 -06:00
2026-01-08 00:42:29 +04:00