0
如何啓用SQL日誌與Batoo JPA與Batoo JPA啓用SQL日誌
如何啓用SQL日誌與Batoo JPA與Batoo JPA啓用SQL日誌
您可以通過
log4j.logger.org.batoo.jpa.core.SQL=DEBUG
在你的log4j.properties
啓用文件
或不處理記錄器並將一個屬性傳遞給persistance.xml,以將sql日誌重定向到STD_OUT或STD_ERR ,如示例所示;
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd" version="2.0">
<persistence-unit name="default">
<provider>org.batoo.jpa.core.BatooPersistenceProvider</provider>
<class>org.batoo.jpa.core.test.simple.Foo</class>
<exclude-unlisted-classes>true</exclude-unlisted-classes>
<properties>
<property name="org.batoo.jpa.ddl" value="DROP" />
<!--org.batoo.jpa.sql_logging :: NONE | STDOUT | STDERR -->
<property name="org.batoo.jpa.sql_logging" value="STDERR" />
</properties>
</persistence-unit>
但使log4j的爲DEBUG級別將記錄的查詢參數的值作爲獎勵,這是更好然後問號。