public interface SqlLogger
该接口定义了 SQL 执行前后日志输出的扩展点,允许用户自定义日志格式、 输出方式(控制台、文件、JSON 等)以及日志级别。
调用时机:
目前定义的业务边界:
框架默认提供一个基础实现,用户可按需替换。
| 限定符和类型 | 方法和说明 |
|---|---|
void |
afterSql(SqlLogProperties props,
SqlLogContext ctx)
SQL 执行后的日志输出。
|
void |
beforeSql(SqlLogProperties props,
SqlLogContext ctx)
SQL 执行前的日志输出。
|
void beforeSql(SqlLogProperties props, SqlLogContext ctx)
通常用于打印 SQL 文本、参数、数据源名称等信息。 此方法不会包含执行耗时与结果,因为 SQL 尚未执行。
props - 日志配置属性ctx - SQL 执行上下文(包含 SQL、参数、数据源等信息)void afterSql(SqlLogProperties props, SqlLogContext ctx)
通常用于打印执行结果、影响行数、返回集合大小、执行耗时等信息。 此方法在 SQL 执行完成后调用,ctx 中包含完整的执行信息。
props - 日志配置属性ctx - SQL 执行上下文(包含执行耗时、返回结果等信息)Copyright © 2024–2026 Dynamic-SQL. All rights reserved.