在我的 MySQL 服务器上,在常规日志中我看到大量如下所示的日志:
2023-03-31T09:31:23.208-07:00 2023-03-31T16:31:23.208345Z37028 Query SET autocommit=0 2023-03-31T09:31:23.211-07:00 2023-03-31T16:31:23.211201Z36956 Query set session transaction read write 2023-03-31T09:31:23.211-07:00 2023-03-31T16:31:23.211807Z36957 Query /* dynamic native SQL query */ select now() /*app health check*/ 2023-03-31T09:31:23.255-07:00 2023-03-31T16:31:23.255990Z36995 Query set session transaction read write 2023-03-31T09:31:23.273-07:00 2023-03-31T16:31:23.273013Z36957 Query set session transaction read write 2023-03-31T09:31:23.276-07:00 2023-03-31T16:31:23.276323Z36956 Query SET autocommit=0 2023-03-31T09:31:23.320-07:00 2023-03-31T16:31:23.320214Z36995 Query SET autocommit=0 2023-03-31T09:31:23.334-07:00 2023-03-31T16:31:23.334801Z36957 Query SET autocommit=0 2023-03-31T09:31:23.461-07:00 2023-03-31T16:31:23.461897Z37056 Query rollback
但是,我希望在客户端日志中看到它们。我的 Java 很生疏,所以请耐心等待。如果它有帮助的话,我要问的问题看起来与这个问题非常相似,尽管那里接受的答案实际上也没有为我解决(这是一个单独的问题):/
我有一个 YAML 文件并尝试启用以下功能:
logging: levels: - path: org.hibernate value: trace - path: org.hibernate.SQL value: debug - path: org.jooq value: trace - path: com.amazonaws value: debug - path: com.zaxxer value: debug - path: com.mysql value: debug - path: org.hibernate.engine.transaction.internal.TransactionImpl value: debug - path: com.mysql.clusterj.core.TransactionImpl value: debug - path: org.hibernate.jpa.internal.TransactionImpl value: debug
P粉1551282112023-09-14 09:03:53
Hibernate 不会发送这些查询。发送它们的是 JDBC 驱动程序。相关的 JDBC API 是 java.sql.Connection.setAutoCommit(),在容器环境中,该方法通常由连接池调用。