日志: app-server 增加 JSON 文件输出供阿里云 SLS 采集 #19

Merged
marco merged 1 commits from feat/sls-json-logging into main 2026-06-07 02:26:46 +08:00
Owner

app/core/logging.py:

  • 新增 RotatingFileHandler 落 logs/app-server.log (此前仅 stdout), 用 JsonFormatter 输出
    单行 JSON (time/level/service/logger/func/line/message, 异常栈内嵌不换行)。
  • 控制台保持文本 (stdout 行为不变, systemd/run.log 不受影响)。
  • setup_logging 加幂等保护 + 清理预置 root handler 防重复输出。
  • 支持环境变量 LOG_FILE/LOG_DIR/LOG_JSON_CONSOLE/LOG_SERVICE_NAME
    (admin 子进程应设独立 LOG_FILE 避免与主进程争抢同一轮转文件)。

Co-Authored-By: Claude Opus 4.8 (1M context) noreply@anthropic.com

app/core/logging.py: - 新增 RotatingFileHandler 落 logs/app-server.log (此前仅 stdout), 用 JsonFormatter 输出 单行 JSON (time/level/service/logger/func/line/message, 异常栈内嵌不换行)。 - 控制台保持文本 (stdout 行为不变, systemd/run.log 不受影响)。 - setup_logging 加幂等保护 + 清理预置 root handler 防重复输出。 - 支持环境变量 LOG_FILE/LOG_DIR/LOG_JSON_CONSOLE/LOG_SERVICE_NAME (admin 子进程应设独立 LOG_FILE 避免与主进程争抢同一轮转文件)。 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
marco added 1 commit 2026-06-07 02:26:41 +08:00
app/core/logging.py:
- 新增 RotatingFileHandler 落 logs/app-server.log (此前仅 stdout), 用 JsonFormatter 输出
  单行 JSON (time/level/service/logger/func/line/message, 异常栈内嵌不换行)。
- 控制台保持文本 (stdout 行为不变, systemd/run.log 不受影响)。
- setup_logging 加幂等保护 + 清理预置 root handler 防重复输出。
- 支持环境变量 LOG_FILE/LOG_DIR/LOG_JSON_CONSOLE/LOG_SERVICE_NAME
  (admin 子进程应设独立 LOG_FILE 避免与主进程争抢同一轮转文件)。

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
marco merged commit f098ba3816 into main 2026-06-07 02:26:46 +08:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: WonderableAI/shaguabijia-app-server#19