-->
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.  [ 4 posts ] 
Author Message
 Post subject: JDK Logging
PostPosted: Fri Mar 09, 2007 9:40 am 
Newbie

Joined: Tue Jan 30, 2007 8:44 am
Posts: 6
Hi,

I need to get hibernate standard output to JDK logging, my current code sets up a JDK logger with a file appender programmatically rather than use a logging.properties file, the logging level is set to finest, I then start hibernate by creating the sessionfactory but all hibernate output is directed to the console, how should I go about directing the hibernate output to my log file?
Does hibernate need to see a logging.properties file?

TIA.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 09, 2007 2:58 pm 
Expert
Expert

Joined: Tue Dec 28, 2004 7:02 am
Posts: 573
Location: Toulouse, France
Hibernate uses the commons-logging. So, it will use JDK logging by default if log4j is not present in the classpath. If you can't wipe out log4j, you can force commons-logging to log with JDK logging system, see configuration properties on the commons-logging project page for more informations.

_________________
Baptiste
PS : please don't forget to give credits below if you found this answer useful :)


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 09, 2007 3:52 pm 
Regular
Regular

Joined: Wed Dec 07, 2005 4:19 pm
Posts: 53
I am afraid the original posting asks about STANDARD OUTOUT.

Hibernate (when configured to do so: hibernate.show_sql) echos all SQL querries - to standard output. I have no idea why this goes to std out when all of the Hibernate is using log4j.

I wish I knew the reasoning behind this decision...

If there is a need for separation of this output, perhaps a separate Appender would do the job ... std out is somewhat difficult to handle.
Or having another property telling it where to direct such output (use log4j instead of std out.) would be a nice feature.

(By the way, the commonly used connection pool also reports errors to Std Out, but there I can understand the motivation: they probably did not want to force the log4j dependency).

Martin.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 09, 2007 6:36 pm 
Expert
Expert

Joined: Tue Dec 28, 2004 7:02 am
Posts: 573
Location: Toulouse, France
mbrunecky wrote:
I am afraid the original posting asks about STANDARD OUTOUT.

Hibernate (when configured to do so: hibernate.show_sql) echos all SQL querries - to standard output. I have no idea why this goes to std out when all of the Hibernate is using log4j.

Well, it's not. You didn't read my answer :). As I said, it's using commons-logging. Log4j is just one logging facility that may be used. In fact, it's often used, but Hibernate has not dependency on it at all.

Imo, if you're right asserting that mikew01 has hibernate.show_sql set to true. Then, he just needs to set it to false. In fact, if he sets it to false, and set the org.hibernate.SQL logger to debug, he will be able to do what he wants with output. These two configurations (hibernate.show_sql or logging via commons-logging) are not related: you could even see both output to the console if the first was set to true and the second configured to use a ConsoleAppender...

Maybe mikew01, you will be limited by the JDK logging possibilities, but what you want to achieve is very very simple and feasible. So, don't worry :).

_________________
Baptiste
PS : please don't forget to give credits below if you found this answer useful :)


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