-->
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 log4j logging problem...
PostPosted: Fri Oct 01, 2004 6:11 am 
Beginner
Beginner

Joined: Mon Mar 29, 2004 12:41 pm
Posts: 26
Hi all ! =)

I have a problem in making log4j work with hibernate. I've put the log4j.properties in my classpath, but, when I change the level of logging ('info' to 'debug' for example), hibernate doesn't take this change in count (it is locked in 'info' mode). Rarely, if I add the 'file' appender declared like this :
log4j.logger.net.sf.hibernate=debug, file
In this case, i have an empty hibernate.log created, but hibernate isn't in debug mode...

I don't really understand the logic of this log4j thing with hibernate...

Any idea ? =)

Thank you.

I use hibernate 2.1 with Oracle9i and here is my log4j.properties file :

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

### 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=debug, 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


Top
 Profile  
 
 Post subject:
PostPosted: Sun Oct 03, 2004 8:18 pm 
Pro
Pro

Joined: Tue Aug 26, 2003 8:07 pm
Posts: 229
Location: Brisbane, Australia
Try adding -Dlog4j.debug=true to your startup command line - this makes log4j print out a bunch of verbose debug info while it is configuring which can help diagnose config problems.

_________________
Cheers,
Shorn.


Top
 Profile  
 
 Post subject: Re: Hibernate log4j logging problem...
PostPosted: Mon Oct 04, 2004 3:33 pm 
Senior
Senior

Joined: Tue Aug 03, 2004 2:11 pm
Posts: 142
Location: Somerset
Teuf wrote:
Hi all ! =)

I have a problem in making log4j work with hibernate.


Hibernate uses commons logging.

There is a somewhat arcane discovery process that works out which logger the commons log factory ends up using.

In your case it is likely that another logger got in there before log4j, and so logging is controlled by the settings for that logger.

Are you using Websphere or WSAD by any chance ? If so I posted a link to an article recently about this whole area. If you are using WSAD teh quickest cop-out way of getting log4j logging out is to delete the ws-commons-logging.jar (or something similar, I forget), from the runtimes lib directory of the built in version(s) of WAS that ship with WSAD.

This is a quick and dirty method for showing up the logging, it has the unfortunate side effect of breaking the classpath of most of your J2EE projects within WSAD, so stick it back in if you want to re-compile anything !

Good luck !

_________________
On the information super B road


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 11, 2004 12:00 pm 
Beginner
Beginner

Joined: Mon Mar 29, 2004 12:41 pm
Posts: 26
Here is my logs after adding the parameter stolley gave me :

Code:
log4j: Trying to find [log4j.xml] using context classloader WebappClassLoader
  available:
    Extension[org.apache.commons.beanutils, implementationVendor=Apache Software Foundation, implementationVersion=1.6, specificationVendor=Apache Software Foundation, specificationVersion=1.6]
    Extension[org.apache.commons.collections, implementationVendor=Apache Software Foundation, implementationVersion=2.1, specificationVendor=Apache Software Foundation, specificationVersion=2.1]
    Extension[org.apache.commons.collections, implementationVendor=Apache Software Foundation, implementationVersion=2.1, specificationVendor=Apache Software Foundation, specificationVersion=2.1]
    Extension[org.apache.commons.digester, implementationVendor="Apache Software Foundation", implementationVersion="1.5", specificationVendor="Apache Software Foundation", specificationVersion="1.5"]
    Extension[commons-fileupload, implementationVendor=Apache Software Foundation, implementationVendorId=, implementationVersion=1.0, specificationVendor=Apache Software Foundation, specificationVersion=]
    Extension[commons-lang, implementationVendor=Apache Software Foundation, implementationVersion=1.0.1, specificationVendor=Apache Software Foundation, specificationVersion=1.0]
    Extension[org.dom4j, implementationVendor= MetaStuff Ltd., implementationVersion=1.3, specificationVendor=MetaStuff Ltd., specificationVersion=1.3]
    Extension[Struts Framework, implementationVendor=Apache Software Foundation, implementationVendorId=org.apache, implementationVersion=1.1, specificationVendor=Apache Software Foundation, specificationVersion=1.1]
  delegate: false
  repositories:
    /WEB-INF/classes/
  required:
----------> Parent Classloader:
StandardClassLoader
  available:
  delegate: true
  repositories:
    file:C:\Program Files\Apache Group\Tomcat 4.1\shared\classes\
  required:
----------> Parent Classloader:
StandardClassLoader
  available:
    Extension[org.apache.tools.ant, implementationVendor=Apache Software Foundation, implementationVersion=1.6.0, specificationVendor=Apache Software Foundation, specificationVersion=1.6.0]
    Extension[org.apache.commons.collections, implementationVendor=Apache Software Foundation, implementationVersion=2.1, specificationVendor=Apache Software Foundation, specificationVersion=2.1]
    Extension[commons-dbcp, implementationVendor=Apache Software Foundation, implementationVendorId=, implementationVersion=1.1, specificationVendor=Apache Software Foundation, specificationVersion=]
    Extension[org.apache.commons.logging, implementationVendor=Apache Software Foundation, implementationVersion=1.0.3, specificationVendor=Apache Software Foundation, specificationVersion=1.0]
    Extension[commons-pool, implementationVendor=Apache Software Foundation, implementationVendorId=, implementationVersion=1.1, specificationVendor=Apache Software Foundation, specificationVersion=]
    Extension[javax.mail, implementationVendor=Sun Microsystems, Inc., implementationVendorId=com.sun, implementationVersion=1.2, specificationVendor=Sun Microsystems, Inc., specificationVersion=1.2]
  delegate: true
  repositories:
    file:C:\Program Files\Apache Group\Tomcat 4.1\common\classes\
    file:C:\Program Files\Apache Group\Tomcat 4.1\common\endorsed\xercesImpl.jar
    file:C:\Program Files\Apache Group\Tomcat 4.1\common\endorsed\xmlParserAPIs.jar
    file:C:\Program Files\Apache Group\Tomcat 4.1\common\lib\activation.jar
    file:C:\Program Files\Apache Group\Tomcat 4.1\common\lib\ant.jar
    file:C:\Program Files\Apache Group\Tomcat 4.1\common\lib\commons-collections.jar
    file:C:\Program Files\Apache Group\Tomcat 4.1\common\lib\commons-dbcp-1.1.jar
    file:C:\Program Files\Apache Group\Tomcat 4.1\common\lib\commons-logging-api.jar
    file:C:\Program Files\Apache Group\Tomcat 4.1\common\lib\commons-pool-1.1.jar
    file:C:\Program Files\Apache Group\Tomcat 4.1\common\lib\jasper-compiler.jar
    file:C:\Program Files\Apache Group\Tomcat 4.1\common\lib\jasper-runtime.jar
    file:C:\Program Files\Apache Group\Tomcat 4.1\common\lib\jdbc2_0-stdext.jar
    file:C:\Program Files\Apache Group\Tomcat 4.1\common\lib\jndi.jar
    file:C:\Program Files\Apache Group\Tomcat 4.1\common\lib\jta.jar
    file:C:\Program Files\Apache Group\Tomcat 4.1\common\lib\mail.jar
    file:C:\Program Files\Apache Group\Tomcat 4.1\common\lib\naming-common.jar
    file:C:\Program Files\Apache Group\Tomcat 4.1\common\lib\naming-factory.jar
    file:C:\Program Files\Apache Group\Tomcat 4.1\common\lib\naming-resources.jar
    file:C:\Program Files\Apache Group\Tomcat 4.1\common\lib\ojdbc14.jar
    file:C:\Program Files\Apache Group\Tomcat 4.1\common\lib\p6spy.jar
    file:C:\Program Files\Apache Group\Tomcat 4.1\common\lib\servlet.jar
    file:C:\Program Files\Apache Group\Tomcat 4.1\common\lib\tools.jar
  required:
----------> Parent Classloader:
sun.misc.Launcher$AppClassLoader@e80a59


.
log4j: Trying to find [log4j.xml] using WebappClassLoader
  available:
    Extension[org.apache.commons.beanutils, implementationVendor=Apache Software Foundation, implementationVersion=1.6, specificationVendor=Apache Software Foundation, specificationVersion=1.6]
    Extension[org.apache.commons.collections, implementationVendor=Apache Software Foundation, implementationVersion=2.1, specificationVendor=Apache Software Foundation, specificationVersion=2.1]
    Extension[org.apache.commons.collections, implementationVendor=Apache Software Foundation, implementationVersion=2.1, specificationVendor=Apache Software Foundation, specificationVersion=2.1]
    Extension[org.apache.commons.digester, implementationVendor="Apache Software Foundation", implementationVersion="1.5", specificationVendor="Apache Software Foundation", specificationVersion="1.5"]
    Extension[commons-fileupload, implementationVendor=Apache Software Foundation, implementationVendorId=, implementationVersion=1.0, specificationVendor=Apache Software Foundation, specificationVersion=]
    Extension[commons-lang, implementationVendor=Apache Software Foundation, implementationVersion=1.0.1, specificationVendor=Apache Software Foundation, specificationVersion=1.0]
    Extension[org.dom4j, implementationVendor= MetaStuff Ltd., implementationVersion=1.3, specificationVendor=MetaStuff Ltd., specificationVersion=1.3]
    Extension[Struts Framework, implementationVendor=Apache Software Foundation, implementationVendorId=org.apache, implementationVersion=1.1, specificationVendor=Apache Software Foundation, specificationVersion=1.1]
  delegate: false
  repositories:
    /WEB-INF/classes/
  required:
----------> Parent Classloader:
StandardClassLoader
  available:
  delegate: true
  repositories:
    file:C:\Program Files\Apache Group\Tomcat 4.1\shared\classes\
  required:
----------> Parent Classloader:
StandardClassLoader
  available:
    Extension[org.apache.tools.ant, implementationVendor=Apache Software Foundation, implementationVersion=1.6.0, specificationVendor=Apache Software Foundation, specificationVersion=1.6.0]
    Extension[org.apache.commons.collections, implementationVendor=Apache Software Foundation, implementationVersion=2.1, specificationVendor=Apache Software Foundation, specificationVersion=2.1]
    Extension[commons-dbcp, implementationVendor=Apache Software Foundation, implementationVendorId=, implementationVersion=1.1, specificationVendor=Apache Software Foundation, specificationVersion=]
    Extension[org.apache.commons.logging, implementationVendor=Apache Software Foundation, implementationVersion=1.0.3, specificationVendor=Apache Software Foundation, specificationVersion=1.0]
    Extension[commons-pool, implementationVendor=Apache Software Foundation, implementationVendorId=, implementationVersion=1.1, specificationVendor=Apache Software Foundation, specificationVersion=]
    Extension[javax.mail, implementationVendor=Sun Microsystems, Inc., implementationVendorId=com.sun, implementationVersion=1.2, specificationVendor=Sun Microsystems, Inc., specificationVersion=1.2]
  delegate: true
  repositories:
    file:C:\Program Files\Apache Group\Tomcat 4.1\common\classes\
    file:C:\Program Files\Apache Group\Tomcat 4.1\common\endorsed\xercesImpl.jar
    file:C:\Program Files\Apache Group\Tomcat 4.1\common\endorsed\xmlParserAPIs.jar
    file:C:\Program Files\Apache Group\Tomcat 4.1\common\lib\activation.jar
    file:C:\Program Files\Apache Group\Tomcat 4.1\common\lib\ant.jar
    file:C:\Program Files\Apache Group\Tomcat 4.1\common\lib\commons-collections.jar
    file:C:\Program Files\Apache Group\Tomcat 4.1\common\lib\commons-dbcp-1.1.jar
    file:C:\Program Files\Apache Group\Tomcat 4.1\common\lib\commons-logging-api.jar
    file:C:\Program Files\Apache Group\Tomcat 4.1\common\lib\commons-pool-1.1.jar
    file:C:\Program Files\Apache Group\Tomcat 4.1\common\lib\jasper-compiler.jar
    file:C:\Program Files\Apache Group\Tomcat 4.1\common\lib\jasper-runtime.jar
    file:C:\Program Files\Apache Group\Tomcat 4.1\common\lib\jdbc2_0-stdext.jar
    file:C:\Program Files\Apache Group\Tomcat 4.1\common\lib\jndi.jar
    file:C:\Program Files\Apache Group\Tomcat 4.1\common\lib\jta.jar
    file:C:\Program Files\Apache Group\Tomcat 4.1\common\lib\mail.jar
    file:C:\Program Files\Apache Group\Tomcat 4.1\common\lib\naming-common.jar
    file:C:\Program Files\Apache Group\Tomcat 4.1\common\lib\naming-factory.jar
    file:C:\Program Files\Apache Group\Tomcat 4.1\common\lib\naming-resources.jar
    file:C:\Program Files\Apache Group\Tomcat 4.1\common\lib\ojdbc14.jar
    file:C:\Program Files\Apache Group\Tomcat 4.1\common\lib\p6spy.jar
    file:C:\Program Files\Apache Group\Tomcat 4.1\common\lib\servlet.jar
    file:C:\Program Files\Apache Group\Tomcat 4.1\common\lib\tools.jar
  required:
----------> Parent Classloader:
sun.misc.Launcher$AppClassLoader@e80a59


class loader.
log4j: Trying to find [log4j.xml] using ClassLoader.getSystemResource().
log4j: Trying to find [log4j.properties] using context classloader WebappClassLoader
  available:
    Extension[org.apache.commons.beanutils, implementationVendor=Apache Software Foundation, implementationVersion=1.6, specificationVendor=Apache Software Foundation, specificationVersion=1.6]
    Extension[org.apache.commons.collections, implementationVendor=Apache Software Foundation, implementationVersion=2.1, specificationVendor=Apache Software Foundation, specificationVersion=2.1]
    Extension[org.apache.commons.collections, implementationVendor=Apache Software Foundation, implementationVersion=2.1, specificationVendor=Apache Software Foundation, specificationVersion=2.1]
    Extension[org.apache.commons.digester, implementationVendor="Apache Software Foundation", implementationVersion="1.5", specificationVendor="Apache Software Foundation", specificationVersion="1.5"]
    Extension[commons-fileupload, implementationVendor=Apache Software Foundation, implementationVendorId=, implementationVersion=1.0, specificationVendor=Apache Software Foundation, specificationVersion=]
    Extension[commons-lang, implementationVendor=Apache Software Foundation, implementationVersion=1.0.1, specificationVendor=Apache Software Foundation, specificationVersion=1.0]
    Extension[org.dom4j, implementationVendor= MetaStuff Ltd., implementationVersion=1.3, specificationVendor=MetaStuff Ltd., specificationVersion=1.3]
    Extension[Struts Framework, implementationVendor=Apache Software Foundation, implementationVendorId=org.apache, implementationVersion=1.1, specificationVendor=Apache Software Foundation, specificationVersion=1.1]
  delegate: false
  repositories:
    /WEB-INF/classes/
  required:
----------> Parent Classloader:
StandardClassLoader
  available:
  delegate: true
  repositories:
    file:C:\Program Files\Apache Group\Tomcat 4.1\shared\classes\
  required:
----------> Parent Classloader:
StandardClassLoader
  available:
    Extension[org.apache.tools.ant, implementationVendor=Apache Software Foundation, implementationVersion=1.6.0, specificationVendor=Apache Software Foundation, specificationVersion=1.6.0]
    Extension[org.apache.commons.collections, implementationVendor=Apache Software Foundation, implementationVersion=2.1, specificationVendor=Apache Software Foundation, specificationVersion=2.1]
    Extension[commons-dbcp, implementationVendor=Apache Software Foundation, implementationVendorId=, implementationVersion=1.1, specificationVendor=Apache Software Foundation, specificationVersion=]
    Extension[org.apache.commons.logging, implementationVendor=Apache Software Foundation, implementationVersion=1.0.3, specificationVendor=Apache Software Foundation, specificationVersion=1.0]
    Extension[commons-pool, implementationVendor=Apache Software Foundation, implementationVendorId=, implementationVersion=1.1, specificationVendor=Apache Software Foundation, specificationVersion=]
    Extension[javax.mail, implementationVendor=Sun Microsystems, Inc., implementationVendorId=com.sun, implementationVersion=1.2, specificationVendor=Sun Microsystems, Inc., specificationVersion=1.2]
  delegate: true
  repositories:
    file:C:\Program Files\Apache Group\Tomcat 4.1\common\classes\
    file:C:\Program Files\Apache Group\Tomcat 4.1\common\endorsed\xercesImpl.jar
    file:C:\Program Files\Apache Group\Tomcat 4.1\common\endorsed\xmlParserAPIs.jar
    file:C:\Program Files\Apache Group\Tomcat 4.1\common\lib\activation.jar
    file:C:\Program Files\Apache Group\Tomcat 4.1\common\lib\ant.jar
    file:C:\Program Files\Apache Group\Tomcat 4.1\common\lib\commons-collections.jar
    file:C:\Program Files\Apache Group\Tomcat 4.1\common\lib\commons-dbcp-1.1.jar
    file:C:\Program Files\Apache Group\Tomcat 4.1\common\lib\commons-logging-api.jar
    file:C:\Program Files\Apache Group\Tomcat 4.1\common\lib\commons-pool-1.1.jar
    file:C:\Program Files\Apache Group\Tomcat 4.1\common\lib\jasper-compiler.jar
    file:C:\Program Files\Apache Group\Tomcat 4.1\common\lib\jasper-runtime.jar
    file:C:\Program Files\Apache Group\Tomcat 4.1\common\lib\jdbc2_0-stdext.jar
    file:C:\Program Files\Apache Group\Tomcat 4.1\common\lib\jndi.jar
    file:C:\Program Files\Apache Group\Tomcat 4.1\common\lib\jta.jar
    file:C:\Program Files\Apache Group\Tomcat 4.1\common\lib\mail.jar
    file:C:\Program Files\Apache Group\Tomcat 4.1\common\lib\naming-common.jar
    file:C:\Program Files\Apache Group\Tomcat 4.1\common\lib\naming-factory.jar
    file:C:\Program Files\Apache Group\Tomcat 4.1\common\lib\naming-resources.jar
    file:C:\Program Files\Apache Group\Tomcat 4.1\common\lib\ojdbc14.jar
    file:C:\Program Files\Apache Group\Tomcat 4.1\common\lib\p6spy.jar
    file:C:\Program Files\Apache Group\Tomcat 4.1\common\lib\servlet.jar
    file:C:\Program Files\Apache Group\Tomcat 4.1\common\lib\tools.jar
  required:
----------> Parent Classloader:
sun.misc.Launcher$AppClassLoader@e80a59


.
log4j: Using URL [file:/C:/Sesam_Vitale/MAJPPS/Code_Java/SMAD/WEB-INF/classes/log4j.properties] for automatic log4j configuration.
log4j: Reading configuration from URL file:/C:/Sesam_Vitale/MAJPPS/Code_Java/SMAD/WEB-INF/classes/log4j.properties
log4j: Parsing for [root] with value=[debug, stdout].
log4j: Level token is [debug].
log4j: Category root set to DEBUG
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 [appli] with value=[debug].
log4j: Level token is [debug].
log4j: Category appli set to DEBUG
log4j: Handling log4j.additivity.appli=[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: Finished configuring.


The Hibernate logger seems to be instanciated... I don't understand... is there a dev to take a look please ?

Thank you ! =)

Teuf


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 13, 2004 4:53 am 
Beginner
Beginner

Joined: Mon Mar 29, 2004 12:41 pm
Posts: 26
Huuhhh... I'm really confused... don't kick my *ss please... but I forgot to include commons-logging.jar in my classpath...

I'm a little bit ashamed...

Thank you all ! =)


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.