-->
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.  [ 9 posts ] 
Author Message
 Post subject: Capturing Hibernate SQLs with Log4J
PostPosted: Wed Mar 21, 2007 1:58 pm 
Beginner
Beginner

Joined: Thu Jun 29, 2006 8:41 am
Posts: 41
Hi,

We're trying to capture the SQL statements created dinamically by Hibernate during execution with Log4J.

I confess I've just dropped into solving this problem but we're getting a very strange problem from what my friend has already done.

We're using a log4j.properties file and setting Log4J through it to print all messages into a log file.

We're using a certain test aplication as a test to this properties file. When we run the program, it prints no messages into the console but prints all of them and the sqls we need into the log file correctly.

Now, in our main application, using the very same properties file and the same log4j.jar file we get a different reaction.

It prints loads of stuff into the console and only prints into the log file the 2 debug lines I directly create in my code (something like: "This is a test.").

Both access the same database and do the same query.

What can be happening here? I don't see any explicit log4j configuration in any class overriding the properties file.

If someone can lead me into the kind of thing I should look for, I'd apreciate.

We're using Hibernate 3.

_________________
Falci - Heavy Worker!


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 21, 2007 4:19 pm 
Expert
Expert

Joined: Tue Jul 11, 2006 10:21 am
Posts: 457
Location: Columbus, Ohio
I believe that Hibernate uses commons-logging to do their logging. I had a similar problem when deploying on Websphere because IBM (in their infinite wisdom) decided that all commons-logging calls should use the JDK logger instead of any configured loggers. Check for commons-logging conflicts in your environment.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 22, 2007 9:26 am 
Beginner
Beginner

Joined: Thu Jun 29, 2006 8:41 am
Posts: 41
Just checked your post.

And my friend has just arrived here too. He reached the very same conclusion that you gave me by himself. So he came to me saying "Hey it works! It's because of..." and I just pointed your post to him. :P

Now it works!

Thanks!

_________________
Falci - Heavy Worker!


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 22, 2007 1:03 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
Interceptor.prepareStatement()

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 29, 2007 9:57 am 
Newbie

Joined: Thu Mar 29, 2007 9:55 am
Posts: 1
So when you say "Check for commons-logging conflicts in your environment" what do you mean to check exactly?


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 02, 2007 11:33 am 
Beginner
Beginner

Joined: Tue May 23, 2006 10:53 am
Posts: 24
Can someone please say clearly ( a little more details) on how to resolve the common-logging conflict on websphere to expose Hibernate log?


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 02, 2007 12:05 pm 
Expert
Expert

Joined: Tue Jul 11, 2006 10:21 am
Posts: 457
Location: Columbus, Ohio
Here is a couple tips. Essentially, if you are trying to use log4j with WAS' commons-logging, it won't work out-of-the-box, a couple of tweaks to prevent this are delineated in the above link.


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 02, 2007 12:13 pm 
Expert
Expert

Joined: Tue Jul 11, 2006 10:21 am
Posts: 457
Location: Columbus, Ohio
Personally, because of this, I use straight log4j and bypass commons-logging. I don't miss the one-off level of indirection that commons-logging provides.


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 03, 2007 5:19 pm 
Beginner
Beginner

Joined: Tue May 23, 2006 10:53 am
Posts: 24
Ananasi :

I solved my problem by going thru the link you posted. Thanks a lot for the help!


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 9 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.