From 8a7144ba42fcc6baa13303f056f6024406991001 Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Fri, 10 Nov 2023 11:19:38 +0100 Subject: [PATCH] =?UTF-8?q?Document=20how=20to=20log=20@=E2=81=A0Sql=20scr?= =?UTF-8?q?ipts=20and=20statements?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes gh-31589 --- .../testing/testcontext-framework/executing-sql.adoc | 9 +++++++++ .../java/org/springframework/test/context/jdbc/Sql.java | 5 +++++ 2 files changed, 14 insertions(+) diff --git a/framework-docs/modules/ROOT/pages/testing/testcontext-framework/executing-sql.adoc b/framework-docs/modules/ROOT/pages/testing/testcontext-framework/executing-sql.adoc index a942993b33..b7ff759e61 100644 --- a/framework-docs/modules/ROOT/pages/testing/testcontext-framework/executing-sql.adoc +++ b/framework-docs/modules/ROOT/pages/testing/testcontext-framework/executing-sql.adoc @@ -183,6 +183,15 @@ script, depending on where `@Sql` is declared. If a default cannot be detected, defined in the class `com.example.MyTest`, the corresponding default script is `classpath:com/example/MyTest.testMethod.sql`. +[[testcontext-executing-sql-declaratively-logging]] +=== Logging SQL Scripts and Statements + +If you want to see which SQL scripts are being executed, set the +`org.springframework.test.context.jdbc` logging category to `DEBUG`. + +If you want to see which SQL statements are being executed, set the +`org.springframework.jdbc.datasource.init` logging category to `DEBUG`. + [[testcontext-executing-sql-declaratively-multiple-annotations]] === Declaring Multiple `@Sql` Sets diff --git a/spring-test/src/main/java/org/springframework/test/context/jdbc/Sql.java b/spring-test/src/main/java/org/springframework/test/context/jdbc/Sql.java index 7cddff0f63..4f4b3a8638 100644 --- a/spring-test/src/main/java/org/springframework/test/context/jdbc/Sql.java +++ b/spring-test/src/main/java/org/springframework/test/context/jdbc/Sql.java @@ -60,6 +60,11 @@ import org.springframework.core.annotation.AliasFor; * for details. This annotation may also be used as a meta-annotation to * create custom composed annotations with attribute overrides. * + *

If you want to see which SQL scripts are being executed, set the + * {@code org.springframework.test.context.jdbc} logging category to {@code DEBUG}. + * If you want to see which SQL statements are being executed, set the + * {@code org.springframework.jdbc.datasource.init} logging category to {@code DEBUG}. + * *

Use of this annotation requires the {@code spring-jdbc} and {@code spring-tx} * modules as well as their transitive dependencies to be present on the classpath. *