How do you enable SQL logging with Batoo JPA
Asked
Active
Viewed 362 times
1 Answers
2
You can enable it by
log4j.logger.org.batoo.jpa.core.SQL=DEBUG
in your log4j.properties file
or without dealing with the logger and pass a property into persistance.xml to redirect the sql log to STD_OUT or STD_ERR as in example;
<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>
But enabling log4j to DEBUG level will log the query parameters values as a bonus which is better then question marks.

asimarslan
- 235
- 1
- 6