在我的 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(),在容器環境中,該方法通常由連線池呼叫。