优化:降低访问日志噪声并增加日志文件轮转

This commit is contained in:
yml2213
2026-08-30 16:59:11 +08:00
parent 6ca54e468e
commit 25b89bb503
20 changed files with 2334 additions and 4 deletions
+4 -1
View File
@@ -40,6 +40,9 @@ npm test
| --- | --- |
| `PORT` | 服务端口(Compose 中常由 `BACKEND_PORT` 映射) |
| `LOG_LEVEL` | `debug` / `info` / `warn` / `error` |
| `LOG_MAX_FILE_SIZE_MB` | 单个应用日志文件大小上限,默认 `20` MB,超出后轮转 |
| `LOG_MAX_FILES` | 同一日期最多保留的日志文件数量,默认 `5`(含当前文件) |
| `LOG_RETENTION_DAYS` | 日志日期保留天数,默认 `30` |
| `DATABASE_URL` | PostgreSQL 连接串 |
| `ADMIN_SESSION_SECRET` | 后台登录态签名密钥 |
| `ADMIN_DEFAULT_USERS_JSON` | 默认后台用户 |
@@ -130,6 +133,6 @@ docker compose -f ../../docker-compose.dev.yml exec -T backend npm run db:migrat
- `data/logs/app-YYYY-MM-DD.log`
- `data/logs/integration-YYYY-MM-DD.log`
按天切分,默认清理过期日志。成功的 `/health*` 探活默认不写 access log。
按天切分并按大小轮转,默认单文件 20MB、单日最多 5 个分片、保留 30 天。成功的 `GET/HEAD` 请求以 `DEBUG` 记录,生产默认 `LOG_LEVEL=info` 不落盘;写请求和所有 4xx/5xx 仍保留 access log。成功的 `/health*` 探活默认不写 access log。
`data/*.json` 为本地运行配置,可能含敏感信息,默认不提交;请从 `*.example.json` 复制后填写。