跳转到正文

系统日志

springboot-business-system-logComponent 采集的日志提供保存、查询和历史迁移能力。

应用可以直接写入数据库或文件,也可以先发送到 RabbitMQ,再由独立服务集中保存。管理端和用户端通过统一 API 查询数据库中的日志。

选择接入方式

你的需求使用方式文档
先跑通日志保存将接口日志写入本地 CSV,无需数据库快速开始
保存到数据库或文件按需引入存储模块,可同时写多个后端日志存储
查看日志列表、详情和统计引入数据库存储与公共 Controller日志查询
多个服务集中保存日志采集端发 MQ,消费端写入存储RabbitMQ
复制或归档已有日志指定一个源和多个目标,显式执行历史迁移

模块如何组成

所有模块的 groupId 均为 com.own.business

模块职责
springboot-business-system-log-business公共数据模型、查询服务和扩展接口
springboot-business-system-log-controller-admin管理端查询 API
springboot-business-system-log-controller-app当前用户的日志查询 API
springboot-business-system-log-persistence-<backend>具体数据库、文件或 MQ 实现
springboot-business-system-log-migration-core历史迁移编排
springboot-business-system-log-migration-<backend>具体迁移源和目标适配

顶层 springboot-business-system-log 及其 persistencemigration 是聚合 POM/BOM。应用引入实际需要的 JAR,版本统一由 Business BOM 管理。

采集、保存与查询的关系

own.system-log.enabled 控制本机采集;文件保存器由 own.system-log.file-<format>.persistence 控制(formatjsoncsvrdbms),数据库和 MQ Producer 保存器由 own.system-log.<backend>.persistence.enabled 控制。一次采集可以写入多个保存器,查询则通过 own.system-log.query.backend 选择一个数据库来源。

MQ 消费和历史迁移各有独立入口。只查询或迁移历史日志时,可以关闭本机采集。

第一次接入请从快速开始开始。

接入调整

当前源码由 UseBusinessSystemLog 统一装配公共能力、已引入的 Controller 和文件存储,无需手动导入已删除的 Controller / 文件模块配置类。数据库、MQ 和迁移继续使用各自的条件配置入口。

从调整前的版本升级时同步修改:

原用法当前用法
com.own.business.system.log.business.*移除 business 包段,例如查询服务在 com.own.business.system.log.service
com.own.business.system.log.persistence.file.<format>.business.* / common.property.*移除 business / common 包段;formatjsoncsvrdbms
own.system-log.file-<format>.persistence.enabledown.system-log.file-<format>.persistence,直接使用布尔值

文件开关旧键不再生效,数据库和 MQ Producer 的 persistence.enabled 保持原用法。关闭文件保存器仍保留显式服务和迁移目标。

按文件查阅方法

重点文件与方法逐项说明核心类、接口和方法重载的用途、参数、返回值、调用示例与注意事项,并链接到公开仓库对应源码。