-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 
Author Message
 Post subject: Hibernate Logging Question
PostPosted: Wed Oct 27, 2010 12:39 pm 
Beginner
Beginner

Joined: Thu Jun 17, 2010 7:36 am
Posts: 26
Hello,

I use Hibernate 3.6.0. Final Release (together with Spring Framework). I've got one question according to the logging.

When I look at "lib -> required" slf4j-api.jar is listed. Does that mean that with Hibernate 3.6.0. I MUST use slf4j-Framework? In the end, slf4j is just a logging api and I must use another framework for logging, like log4j or jcl. Does Hibernate 3.6.0 really require slf4j?

Beside of this, I got more confused, because while reading through the web I found two more different statements: the first was, that JCL is required while using Hibernate, the second was that log4j must be used while using hibernate. I would really like to know what I HAVE to use when I use Hibernate 3.6.0.

At the moment I use all three frameworks: log4j, because I like it for logging, jcl, because I need it for spring and slf4j because I can redirect jcl (from spring) to log4j and so log4j use for everything. this works fine, but Im interested in knowing if using slf4j is inevitable for using hibernate (with logging).

thanks for an answer!


Top
 Profile  
 
 Post subject: Re: Hibernate Logging Question
PostPosted: Wed Oct 27, 2010 7:40 pm 
Regular
Regular

Joined: Sun Feb 14, 2010 3:29 pm
Posts: 58
Location: USA
Yes Hibernate 3.6.0 requires slf4j.jar.

You should read up what slf4j is and how it works. It basically just providing a API set that other application (like hibernate) can compile against it and starting use a Logger object that has no implementation to it. To see any logging, you must choose a slf4j logging implementation (eg: log4j, jdk, or logback). So yes, whenever you (or any application that) use slf4j, you always needs the actual logging implementation go with it. Think of slf4j as an Java interface that always needs a concrete class to do something useful.

In your case, to use log4j and slf4j cleanly with Hibernate and Spring, you can exclude the commons logging from Spring dependency. You need to use the jcl-over-sl4j.jar that acts just one, but it will actually redirect all calls into to slf4j, then in turn use your log4j as actual logging. http://www.slf4j.org/legacy.html

If you look at latest Spring release of maven dep, they don't even bring in commons-logging anymore, and so you don't even need to exclude it explicitly. Read their ref manual, and they even give you example on how to do this.

_________________
Zemian Deng
------------
Need a Java Scheduler? Try
http://bitbucket.org/timemachine/scheduler


Top
 Profile  
 
 Post subject: Re: Hibernate Logging Question
PostPosted: Thu Oct 28, 2010 5:32 am 
Beginner
Beginner

Joined: Thu Jun 17, 2010 7:36 am
Posts: 26
first thank you for your answer!!!

I almost already wrote what you said:

Quote:
In the end, slf4j is just a logging api and I must use another framework for logging, like log4j or jcl.


and

Quote:
log4j, because I like it for logging, jcl, because I need it for spring and slf4j because I can redirect jcl (from spring) to log4j and so log4j use for everything.


:-)

I use Spring Framework 3.0.4 and Spring Security 3.1.0. (and I dont use maven)
Without jcl (or redirecting jcl to slf4j) it does not work. I read a lot of that manuals, would you show me where to find the lines you talked about? that would be nice!

thank you!


Top
 Profile  
 
 Post subject: Re: Hibernate Logging Question
PostPosted: Thu Oct 28, 2010 6:45 am 
Beginner
Beginner

Joined: Thu Jun 17, 2010 7:36 am
Posts: 26
I've got one more question.

I read about JCL and I found out that JCL tries to "combine" log4j and a logging API from Sun, JSR 47. This is criticized, because JSR 47 does not work as well as log4j and combining log4j and jsr 47 causes problems in practice.

But: I found this out while researching on the internet. When I read the homepage from JCL (http://commons.apache.org/logging/) I can not find out anything about combining log4j and jsr 47 with it. (maybe I overread it?)
is my information maybe an old information and is jsr 47 not a part of jcl anymore? then maybe the criticism on it is not justifiable anymore?

I would be very interested in knowing more about this. it would be great if someone could answer me! thank you!


Top
 Profile  
 
 Post subject: Re: Hibernate Logging Question
PostPosted: Thu Oct 28, 2010 7:40 am 
Beginner
Beginner

Joined: Thu Jun 17, 2010 7:36 am
Posts: 26
I also would like to understand how JCL exactly works, when it tries to combine log4j (logging-framework!) and jsr 47 (logging api? does not implement logging?)

it confuses me...


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.