Home > Java > javaTutorial > Why Are My SQL Statements Not Logging to File in Spring Boot?

Why Are My SQL Statements Not Logging to File in Spring Boot?

Susan Sarandon
Release: 2024-11-20 11:54:18
Original
620 people have browsed it

Why Are My SQL Statements Not Logging to File in Spring Boot?

Logging SQL Statements in Spring Boot

When trying to log SQL statements to a file, many encounter difficulties despite properly configuring application.properties. While enabling SQL statement printing to the console with spring.jpa.show-sql=true and formatting with spring.jpa.properties.hibernate.format_sql=true, the statements fail to appear in the desired log file.

To resolve this issue, the following properties should be added to the properties file:

  • logging.level.org.hibernate.SQL=DEBUG
  • logging.level.org.hibernate.type.descriptor.sql.BasicBinder=TRACE

These settings ensure that SQL statements are logged at the DEBUG level. When combined with the INFO logging level for Spring and Hibernate, SQL statements will be captured and recorded in the specified log file.

The above is the detailed content of Why Are My SQL Statements Not Logging to File 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