Hello. I cannot set hibernate to write SQL request parameters values to log.
I work on project and it uses hibernate 4.1.8. After some search I found two solutions other people use for that but I was not able to make them work:
- set logging property
org.hibernate.type to ALL. Later about that.
- use
P6Spy - third party SQL driver. I was not able even set SQL connection. It crashes on first request and its description looks outdated.
As I would like not to take third party software even for debug, it would be much better to get how to set org.hibernate.type property.
I tried to set it in
log4j.properties file:
Code:
log4j.logger.org.hibernate.type=ALL
I tried to set it in
log4j.xmlCode:
<logger name="org.hibernate.type">
<level value="trace"/>
</logger>
I know log4j reads xml config for sure, as I get errors in log if I put some wrong tags in log4j.xml.
Unfortunately this not works. May be
pom.xml file broken. All I was able to get - SQL commands written to console, but only with
hibernate.cfg.xmlCode:
<property name="hibernate.show_sql">true</property>
Also I saw some info that this could be caused by absent dependencies. I put in pom.xml anything could solve but no luck:
Code:
<!--hibernate -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>4.1.8.Final</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator-annotation-processor</artifactId>
<version>4.1.0.Final</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.7.7</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.7</version>
</dependency>
<dependency>
<groupId>org.jboss.logging</groupId>
<artifactId>jboss-logging</artifactId>
<version>3.2.0.Final</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.16</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>4.1.8.Final</version>
<scope>compile</scope>
<type>jar</type>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- Hibernate Spatial for mysql. This will include Hibernate Spatial Core and JTS -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-spatial</artifactId>
<version>4.0.1</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- custom type mappings for java 8 time classes -->
<!--hibernate -->
<dependency>
<groupId>ca.gfisystems</groupId>
<artifactId>hibernate-utils</artifactId>
<version>1.0</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- c3p0 used for postgresql connection -->
<dependency>
<groupId>c3p0</groupId>
<artifactId>c3p0</artifactId>
<version>0.9.1.2</version>
</dependency>
<!-- hibernate c3p0 connection pooling -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-c3p0</artifactId>
<version>4.1.8.Final</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- logback -->
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.1.3</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-core</artifactId>
<version>1.1.3</version>
</dependency>
Please help. It could be that I just search i wrong place and get many search results, but they are outdated. Link to relevant manual would be nice too.
Thanks.