我想在一个文件中记录SQL语句。
我在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
当我运行应用程序时
cmd>mvn spring-boot:run
我可以在控制台中看到sql语句,但它们不会出现在文件app.log中。该文件只包含spring的基本日志。
我应该怎么做才能在日志文件中看到sql语句?
发布于 2015-07-06 23:39:30
尝试在您的属性文件中使用以下内容:
logging.level.org.hibernate.SQL=DEBUG
logging.level.org.hibernate.type.descriptor.sql.BasicBinder=TRACE
发布于 2016-05-26 23:20:33
这也适用于stdout:
spring.jpa.properties.hibernate.show_sql=true
spring.jpa.properties.hibernate.use_sql_comments=true
spring.jpa.properties.hibernate.format_sql=true
要记录值,请执行以下操作:
logging.level.org.hibernate.type=trace
只需将此添加到application.properties
即可。
发布于 2017-01-11 23:37:57
这对我很有效(YAML):
spring:
jpa:
properties:
hibernate:
show_sql: true
format_sql: true
logging:
level:
org:
hibernate:
type: trace
https://stackoverflow.com/questions/30118683
复制相似问题