如何在Spring Boot中记录SQL语句? [英] How to log SQL statements in Spring Boot?
本文介绍了如何在Spring Boot中记录SQL语句?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在文件中记录SQL语句.
我在application.properties
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
我可以在控制台中看到sql语句,但是它们未出现在文件app.log中.该文件仅包含来自spring的基本日志.
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.
如何查看日志文件中的sql语句?
What should I do to see sql statements in the log file?
推荐答案
尝试在属性文件中使用它:
try using this in your properties file:
logging.level.org.hibernate.SQL=DEBUG
logging.level.org.hibernate.type.descriptor.sql.BasicBinder=TRACE
这篇关于如何在Spring Boot中记录SQL语句?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文