简体   繁体   English

如何记录由 Quarkus 应用程序创建的 SQL 语句?

[英]How can I log SQL statements in created by my Quarkus application?

I am using Quarkus application with the Hibernate extension and I would like Hibernate to show the generated SQL query.我正在使用带有 Hibernate 扩展的 Quarkus 应用程序,我希望 Hibernate 显示生成的 SQL 查询。 I am not sure how that could be accomplished.我不确定如何实现。

What's the best way to accomplish that?实现这一目标的最佳方法是什么? What's the proper way to configure such a feature?配置此类功能的正确方法是什么?

The Quarkus property that controls this behavior is quarkus.hibernate-orm.log.sql (which is set to false by default).控制此行为的 Quarkus 属性是quarkus.hibernate-orm.log.sql (默认设置为false )。

By simply setting quarkus.hibernate-orm.log.sql=true in application.properties , Quarkus will show and format the SQL queries that Hibernate issues to the database.通过简单地在application.properties设置quarkus.hibernate-orm.log.sql=true ,Quarkus 将显示和格式化 Hibernate 向数据库发出的 SQL 查询。 Note that the Hibernate configuration is not overridable at runtime.请注意,Hibernate 配置在运行时不可覆盖。

For a complete set of properties that can be used to control Quarkus/Hibernate behavior, see this guide有关可用于控制 Quarkus/Hibernate 行为的完整属性集,请参阅指南

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM