Home > Java > javaTutorial > How to Log SQL Statements in Spring Boot?

How to Log SQL Statements in Spring Boot?

Linda Hamilton
Release: 2024-11-14 11:18:01
Original
311 people have browsed it

How to Log SQL Statements in Spring Boot?

Logging SQL Statements in Spring Boot

In Spring Boot, you can configure logging to output SQL statements to a file. This can be useful for debugging or tracing the execution of database operations. By default, Spring Boot does not log SQL statements.

To log SQL statements, you can add the following properties to your application.properties file:

logging.level.org.hibernate.SQL=DEBUG
logging.level.org.hibernate.type.descriptor.sql.BasicBinder=TRACE
Copy after login

The above properties set the logging level for the Hibernate SQL logger and the BasicBinder logger to DEBUG and TRACE respectively. This will log all SQL statements and their bound parameters.

Once you have added these properties, you can run your application and check the log file to see the SQL statements.

The above is the detailed content of How to Log SQL Statements in Spring Boot?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template