Show SQL Statements in Spring Boot Logs

Spring Boot

This Java article explains how to show SQL statements or queries generated by JPA or Hibernate in the Spring Boot Application logs.

For logging SQL statements generated by Spring Data JPA / Hibernate, add below property to your application.properties configuration file.

To beautify or pretty print the SQL queries, you can add:

Here is the log output.

Hibernate:
    select
        product0_.id as id1_0_0_,
        product0_.description as descript2_0_0_,
        product0_.image_url as image_ur3_0_0_,
        product0_.price as price4_0_0_,
        product0_.product_id as product_5_0_0_,
        product0_.version as version6_0_0_
    from
        product product0_
    where
        product0_.id=?
Share This Post On: