Home > Java > javaTutorial > Why Aren't My Spring Boot SQL Statements Being Logged to a File?

Why Aren't My Spring Boot SQL Statements Being Logged to a File?

Linda Hamilton
Release: 2024-11-29 00:16:11
Original
621 people have browsed it

Why Aren't My Spring Boot SQL Statements Being Logged to a File?

Logging SQL Statements in Spring Boot

Despite enabling SQL statement display and formatting in application.properties, SQL statements are not being logged to the designated file.

Issue

In your configuration, you've specified:

spring.jpa.show-sql=true
spring.jpa.properties.hibernate.format_sql=true
Copy after login

While these settings allow for console logging of SQL statements, they do not redirect them to a log file.

Solution

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

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

Explanation

  • logging.level.org.hibernate.SQL=DEBUG: Sets the log level for Hibernate SQL statements to DEBUG.
  • logging.level.org.hibernate.type.descriptor.sql.BasicBinder=TRACE: Sets the log level for Hibernate SQL parameter binding to TRACE.

The above is the detailed content of Why Aren't My Spring Boot SQL Statements Being Logged to a File?. 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