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.  [ 13 posts ] 
Author Message
 Post subject: Hibernate not logging information
PostPosted: Fri Dec 17, 2004 4:59 pm 
Newbie

Joined: Mon Dec 13, 2004 5:27 pm
Posts: 7
I feel kind of dumb asking this because I'm sure it's a problem between the chair and keyboard, but I am not able to get Hibernate to log any messages using Log4j. I've debugged the Hibernate code and it jumps right over all logging statements. I'm using Hibernate 2.1.

I know Hibernate is reading the log4j.properties file because if I put in something invalid in it Hibernate complains.

Log4j.properties is in my classpath. Other debug messages outside of Hibernate in my own app are logging properly. The only other thing I can think of is that I'm using Spring and Hibernate together and that is causing some problem.

With hibernate.show_sql=true, I do see the sql in my console so some things are logging properly.

Is there something in my hibernate.properties that I need to have to turn on logging for debug, info, trace etc messages?

I'm at a loss here. Any help would be appreciated.

Log4j.properties

Code:
### direct log messages to stdout ###
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n
#log4j.appender.stdout.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n

### direct messages to file hibernate.log ###
#log4j.appender.file=org.apache.log4j.FileAppender
#log4j.appender.file.File=hibernate.log
#log4j.appender.file.layout=org.apache.log4j.PatternLayout
#log4j.appender.file.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n

### set log levels - for more verbose logging change 'info' to 'debug' ###

log4j.rootLogger=warn, stdout

log4j.logger.net.sf.hibernate=debug

### log just the SQL
#log4j.logger.net.sf.hibernate.SQL=debug

### log JDBC bind parameters ###
log4j.logger.net.sf.hibernate.type=debug

### log schema export/update ###
log4j.logger.net.sf.hibernate.tool.hbm2ddl=debug

### log cache activity ###
#log4j.logger.net.sf.hibernate.cache=debug

### enable the following line if you want to track down connection ###
### leakages when using DriverManagerConnectionProvider ###
#log4j.logger.net.sf.hibernate.connection.DriverManagerConnectionProvider=trace

log4j.logger.com.amfam.dmie=debug


Thanks,
joatmon


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 17, 2004 5:06 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
don't know if it is a conincidence, but you write Log4j.properties twice, and the file name should be log4j.properties (lower case)

and the show_sql uses direct system.out so that is not via any logging system FYI.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 17, 2004 5:26 pm 
Newbie

Joined: Mon Dec 13, 2004 5:27 pm
Posts: 7
max wrote:
don't know if it is a conincidence, but you write Log4j.properties twice, and the file name should be log4j.properties (lower case)


Just a coincidence. I do have log4j.properties. Sorry for the confusion.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 17, 2004 5:44 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
and you do have log4j.jar in your classpath ? ;)

tip: try to pass -Dlog4j.debug=true to your vm and see what happens ....if nothing, you surely don't have log4j installed properly - otherwise you will be told what happens in the output ;)

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 22, 2004 5:37 pm 
Newbie

Joined: Mon Dec 13, 2004 5:27 pm
Posts: 7
max wrote:
and you do have log4j.jar in your classpath ? ;)

tip: try to pass -Dlog4j.debug=true to your vm and see what happens ....if nothing, you surely don't have log4j installed properly - otherwise you will be told what happens in the output ;)


I put log4j.debug=true in my log4j.properties and get the following multiple times:

Code:
log4j: Level token is [warn].
log4j: Category root set to WARN
log4j: Parsing appender named "stdout".
log4j: Parsing layout options for "stdout".
log4j: Setting property [conversionPattern] to [%d{ABSOLUTE} %5p %c{1}:%L - %m%n].
log4j: End of parsing for "stdout".
log4j: Setting property [target] to [System.out].
log4j: Parsed "stdout" options.
log4j: Parsing for [com.amfam.dmie] with value=[debug].
log4j: Level token is [debug].
log4j: Category com.amfam.dmie set to DEBUG
log4j: Handling log4j.additivity.com.amfam.dmie=[null]
log4j: Parsing for [net.sf.hibernate.type] with value=[debug].
log4j: Level token is [debug].
log4j: Category net.sf.hibernate.type set to DEBUG
log4j: Handling log4j.additivity.net.sf.hibernate.type=[null]
log4j: Parsing for [net.sf.hibernate] with value=[debug].
log4j: Level token is [debug].
log4j: Category net.sf.hibernate set to DEBUG
log4j: Handling log4j.additivity.net.sf.hibernate=[null]
log4j: Parsing for [net.sf.hibernate.tool.hbm2ddl] with value=[debug].
log4j: Level token is [debug].
log4j: Category net.sf.hibernate.tool.hbm2ddl set to DEBUG
log4j: Handling log4j.additivity.net.sf.hibernate.tool.hbm2ddl=[null]
log4j: Finished configuring.


But there are no hibernate logged messages in the log. There are messages from my application but nothing from hibernate. Could it be a case issue (DEBUG vs. debug)?

Thanks,
joatmon


Top
 Profile  
 
 Post subject: What version of Hibernate are you using?
PostPosted: Wed Dec 22, 2004 8:46 pm 
Contributor
Contributor

Joined: Thu Nov 06, 2003 9:49 pm
Posts: 104
Location: New York, NY
If you are using Hibernate3, all the categories are 'org.hibernate' instead of 'net.sf.hibernate'.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 23, 2004 4:02 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
can it be that hibernate and your app is loading from different classloaders, then log4j (or rather commons-logging can get confused)

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 12, 2005 12:08 pm 
Newbie

Joined: Mon Dec 13, 2004 5:27 pm
Posts: 7
max wrote:
can it be that hibernate and your app is loading from different classloaders, then log4j (or rather commons-logging can get confused)


You were correct that the issue was with the classloader. We are using Websphere 5.0. For both the EAR file and the WAR file in the server configuration we had to set the classloader mode to PARENT_LAST and the WAR classloader policy to MODULE. This fixed the problem that I was seeing and now both Spring and Hibernate are logging all of their messages. Thanks for your help.

--joatmon


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 12, 2005 11:13 pm 
Beginner
Beginner

Joined: Wed Nov 10, 2004 5:48 pm
Posts: 32
Location: Portland
This is made so difficult because commons-logging is a bad idea. http://www.qos.ch/logging/thinkAgain.jsp

The convoluted classloader hierarchy in websphere does not help either!


Top
 Profile  
 
 Post subject: logging hibernate on WebSphere 5.1.1, jdk1.4, struts
PostPosted: Thu Jan 27, 2005 6:53 pm 
Beginner
Beginner

Joined: Thu Jan 27, 2005 6:31 pm
Posts: 21
Location: This Life - Planet Earth
joatmon wrote:
You were correct that the issue was with the classloader. For both the EAR file and the WAR file in the server configuration we had to set the classloader mode to PARENT_LAST and the WAR classloader policy to MODULE. This fixed the problem.
--joatmon


All;
<quote>PAMHO</quote>
I am using hibernate 2.1.7.c with WebSphere 5.1.1 and get the same problem with the hibernate logging not working. The fix by "joatmon" does not work for us since changing the classloader options breaks the web services and struts etc in the application. (I dont kwow why!!). I tried various classloader options in WebSphere - no luck. Is there some other fix someone is aware of ? Or is there some article or document that explains the problem with commons-logging with struts and jdk 1.4 etc more clearly with possible workarounds that I can understand.
I am still trying but cant think of any ideas.
Jenn.
-------


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 27, 2005 8:10 pm 
Beginner
Beginner

Joined: Thu Jan 27, 2005 6:31 pm
Posts: 21
Location: This Life - Planet Earth
<quote PAMHO</quote>
ok got this working. Am still testing the solutions. will post as soon as done.
-J


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 22, 2005 11:59 am 
Newbie

Joined: Thu Apr 21, 2005 9:34 pm
Posts: 4
It took a couple of hours to piece the following together. The necessary documentation does exist, but it is still not well-organized. Hopefully, this will help some of you get file logging going in minutes instead of hours:

1. Copy both of the following into your classes folder:

log4j.properties
commons-logging.properties

2. Replace the one line in the commons-logging.properties file with this:

org.apache.commons.logging.Log=org.apache.commons.logging.impl.Log4JLogger

3. Make sure the following are in your log4j.properties file

Code:
log4j.appender.file=org.apache.log4j.FileAppender
log4j.appender.file.File=D:\\hibernate.log 

Note the \\s above if you're using Windows

and also

Code:
log4j.logger.net.sf.hibernate=debug,file


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 26, 2005 7:07 am 
Beginner
Beginner

Joined: Thu Apr 21, 2005 12:15 pm
Posts: 34
Could anyone clarify how to get this working with Websphere (im using Websphere 6 but guess its the same as Websphere 5).
I would actually rather use the standard JDK 1.4 logging can this be done.


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