Files
open-webui-ai4me/backend/open_webui
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-22 17:28:01 -06:00
2026-02-21 15:35:34 -06:00
2026-02-22 17:05:39 -06:00
2026-02-19 16:32:41 -06:00
2025-08-10 00:02:58 +04:00
2026-02-11 16:24:11 -06:00
2026-02-21 14:19:28 -06:00
2026-02-19 14:06:24 -06:00
2025-04-15 09:55:35 +02:00
2026-02-11 16:24:11 -06:00
2026-02-12 15:29:34 -06:00