views:

152

answers:

2

In my application I'm using Hibernate, Apache Commons Logging and Log4J. But my log files are not getting generated. Is these because Hibernate uses slf4j?

In my classpath I have the following jars.

  • hibernate-3.2.7.ga.jar
  • hibernate-annotations-3.4.0.GA.jar
  • hibernate-commons-annotations-3.3.0.ga.jar
  • hibernate-core-3.3.2.GA.jar
  • hibernate-entitymanager-3.4.0.GA.jar
  • slf4j-api-1.5.6.jar
  • slf4j-jcl-1.5.6.jar
  • commons-logging-1.1.1.jar
  • log4j-1.2.16.jar
  • log4j.properties

I found that Hibernate uses slf4j. I want the logging to be delegated in the following route -

slf4j-api -> slf4j-jcl -> commons-logging -> log4j

But neither I'm getting the Hibernate logs, nor my application logs.

What could be the reason?

+1  A: 

Starting with version 3.3, Hibernate indeed uses SFL4J instead of JCL (this is HHH-2696) and your dependencies delegate calls to SLF4J to JCL look correct.

However, why do you have both hibernate-3.2.7.ga.jar (which BTW uses Commons Logging) and hibernate-core-3.3.2.GA.jar? I wonder if this doesn't cause any conflict. Try to clean your class path and see if you don't get any error trace at startup after that.

But I would personally try to get rid of JCL instead of delegating to it. If you have some code that uses JCL and if JCL is not a formal requirement, replace commons-logging-1.1.1.jar with jcl-over-slf4j.jar (a JCL-over-SLF4J bridge).

See also

Pascal Thivent
In my project I'm using Hibernate as a JPA provider only. But I'm confused regarding the set of Hibernate jars to use.
Kalyan Sarkar
I excluded the hibernate-3.2.7.ga.jar from classpath as you suggested and there were no problems. Thank you for pointing out my mistake.The log files however are not generated as usual.
Kalyan Sarkar
A: 

I'm here to mention that I've solved the issue.

I was using wife and the jar has a log4j.properties within it. It was getting loaded before my application's log4j.properties. I've reversed the order and it works now!

Thank you folks, especially for helping me out with Hibernate jars.

Kalyan Sarkar