iotsaas/backend/deploy/systemd/journald-iotsaas.conf
2995840376 b2d758be33 fix(F): 日志轮转治理 - 统一 logback 配置 + journald 限额
问题根因:
- iot-device.out 涨到 613MB:systemd StandardOutput=append: 无任何轮转
- DEBUG 刷屏(单日 11521 条):logging.level.com.iot=DEBUG 使 MyBatis 每条 SQL 打印两遍
- 涂鸦 open-mq-sdk jar 自带 logback.xml 抢占日志配置(iot-data/rule/alarm 未声明 logging.config),
  把日志写到 ./logs 相对目录且无总量上限

改动:
- 新增 backend/iot-common/src/main/resources/logback-spring.xml(4 服务共用唯一真相源):
  RollingFileAppender 按日 + 50MB 双触发切分,保留 7 天,主日志总量上限 2GB,
  错误日志单独一份(保留 30 天 / 512MB),并对涂鸦/MQTT/AMQP 等第三方 SDK 降噪
- 父 pom 增加 maven-resources-plugin,把该配置复制进各服务 BOOT-INF/classes
- 4 个服务 application.yml 统一声明 logging.config,并把 com.iot 级别收敛为 INFO
- 新增 backend/deploy/systemd/:4 个 unit 改为 StandardOutput=journal + 注入 LOG_DIR,
  附 journald 限额(SystemMaxUse=1G / SystemMaxFileSize=50M / MaxRetentionSec=7day)
- deploy-all.bat 增加日志治理步骤(同步 unit + journald + 清理历史 .out)

生产验证:日志落到 /opt/iotsaas/logs/app/*.log,DEBUG 计数 0,历史 .out 已清理,
journal 776M 降到 552M,4 服务 active,9081/9083 文档返回 200
2026-10-27 18:28:19 +08:00

9 lines
282 B
Plaintext
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

[Journal]
# iotsaas 日志治理:限制 journal 体积,避免 /var/log/journal 无限增长
# (Ubuntu 默认 SystemMaxUse = 磁盘的 10%,本机 1.8T 盘即 180G,过大)
Storage=persistent
SystemMaxUse=1G
SystemMaxFileSize=50M
SystemMaxFileSec=1day
MaxRetentionSec=7day