Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
3 views
in Java by (4k points)

I want to log SQL statements in a file.

I have the following properties in application.properties

spring.datasource.url=...

spring.datasource.username=user

spring.datasource.password=1234

spring.datasource.driver-class-name=net.sourceforge.jtds.jdbc.Driver

spring.jpa.show-sql=true

spring.jpa.properties.hibernate.format_sql=true

security.ignored=true

security.basic.enabled=false

logging.level.org.springframework.web=INFO

logging.level.org.hibernate=INFO

logging.file=c:/temp/my-log/app.log

When I run my application

cmd>mvn spring-boot:run

I can see SQL statements in the console but they don't appear in a file app.log. The file contains only basic logs from spring.

What should I do to see SQL statements in the log file?

1 Answer

0 votes
by (46k points)

Analyze applying this in your resource file:

logging.level.org.hibernate.SQL=DEBUG

logging.level.org.hibernate.type.descriptor.sql.BasicBinder=TRACE

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...