Skip to content

fix: 限制日志暴涨并修复启动日志兼容问题#319

Open
piexian wants to merge 1 commit intochenyme:mainfrom
piexian:fix_upstream_log_refresh_stability
Open

fix: 限制日志暴涨并修复启动日志兼容问题#319
piexian wants to merge 1 commit intochenyme:mainfrom
piexian:fix_upstream_log_refresh_stability

Conversation

@piexian
Copy link
Contributor

@piexian piexian commented Mar 12, 2026

Summary

修复长期运行时由请求侧 Token 刷新触发的日志暴涨与容器卡顿问题,并补充日志轮转配置与后台配置项。

具体包括:

  • 为请求侧 cooling token 刷新增加限流、并发保护和单次最大检查数量,避免 refresh 风暴
  • 下调高频成功日志等级,减少 Usage sync success / Token refreshed 等逐 Token 日志噪音
  • 将请求日志改为默认只记录慢请求和错误请求,降低 /health 与高频接口日志量
  • 为文件日志增加最大文件大小、最大保留数量配置,并在后台配置页暴露对应选项
  • 修复 Loguru JSON sink 在启动阶段的兼容问题

Changes

  • 功能新增
  • Bug 修复
  • 重构/清理
  • 文档更新
  • 其他(请说明)

Related Issues

N/A

Verification

  • 本地运行验证
  • 单元/集成测试
  • Docker 构建通过
  • 未验证(请说明原因)

验证说明:

- UV_CACHE_DIR=/tmp/uv-cache RUFF_CACHE_DIR=/tmp/ruff-cache uv run ruff check app/core/logger.py main.py app/api/v1/admin/config.py app/core/response_middleware.py app/services/reverse/app_chat.py app/services/grok/batch_services/usage.py app/services/grok/utils/retry.py app/services/token/manager.py 通过
- docker compose up --build -d 重建并启动成功
- curl http://127.0.0.1:8000/health 返回 {"status":"ok"}
- 检查最近容器日志,未再出现 Logging error / KeyError

Breaking Changes

  • 有(请说明迁移方式)

@piexian piexian force-pushed the fix_upstream_log_refresh_stability branch from 1d7abde to d31ea0b Compare March 12, 2026 19:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant