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:
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!