-->
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: I can't turn on logging - very strange
PostPosted: Tue Feb 03, 2004 1:01 pm 
Newbie

Joined: Thu Dec 04, 2003 9:07 am
Posts: 7
Location: Johannesburg
I'm experimenting with Hibernate 2.1 in a stand-alone application running on Netbeans.

I am trying to turn on log4j logging, unsuccesfully. I have log4j.jar and log4j.properties on my classpath. I am able to use logging in my own code, and affect its behaviour by settings in the log4j.properties file. I cannot turn on logging for the log4j code however.

Here are the contents of log4j.properties

### 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.rootLogger=debug, stdout
log4j.logger.net.sf.hibernate=debug
log4j.logger.net.sf.hibernate.type=debug
log4j.logger.net.sf.hibernate.tool.hbm2ddl=debug
log4j.logger.mystuff=debug

My code, in package mystuff is using logging no problems.

Any ideas??

Thanks for your help
Jairaj


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 04, 2004 5:20 am 
Beginner
Beginner

Joined: Tue Nov 11, 2003 4:49 am
Posts: 47
Location: Florence, Italy
Hibernate use commons-logging, so you must tell this wrapper to use log4j, setting this property:
Code:
org.apache.commons.logging.log=org.apache.commons.logging.impl.Log4JCategory

Ciao.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 04, 2004 7:38 am 
Newbie

Joined: Thu Dec 04, 2003 9:07 am
Posts: 7
Location: Johannesburg
Thanks for the help

I created the property in the hibernate.cfg file. That didn't work. Where should I create the property?

I thought commons-logging worked out whether to use log4j or jdk1.4 logging for itself, by checking for log4j on the classpath.

Thanks again,
Jairaj


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 04, 2004 7:47 am 
Beginner
Beginner

Joined: Tue Nov 11, 2003 4:49 am
Posts: 47
Location: Florence, Italy
With -D as JVM parameter.
Ciao.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 04, 2004 7:49 am 
Newbie

Joined: Thu Dec 04, 2003 9:07 am
Posts: 7
Location: Johannesburg
Ok I created a commons-logging.properties file.

Now I get a ClassNotFoundException for org.apache.commons.logging.impl.Log4JCategory


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 04, 2004 7:52 am 
Newbie

Joined: Thu Dec 04, 2003 9:07 am
Posts: 7
Location: Johannesburg
I used
org.apache.commons.logging.log=org.apache.commons.logging.impl.Log4JCategoryLog

That works now, thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 04, 2004 8:33 am 
Beginner
Beginner

Joined: Tue Nov 11, 2003 4:49 am
Posts: 47
Location: Florence, Italy
Anywat I think that putting it into the hibernate.cfg.xml would be a good idea !!!
Ciao.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 04, 2004 9:53 am 
Proxool Developer
Proxool Developer

Joined: Tue Aug 26, 2003 10:42 am
Posts: 373
Location: Belgium
l.masini wrote:
Anywat I think that putting it into the hibernate.cfg.xml would be a good idea !!!
Ciao.


As per the commons-logging documentation, this should not be required: by default commons-logging switch to Log4J if found in the classpath...


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 04, 2004 11:09 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
l.masini wrote:
Anywat I think that putting it into the hibernate.cfg.xml would be a good idea !!!
Ciao.

I disagree, Hibernate isn't the only framework using commons-logging. having it's config in Hibernate config would sucks.

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 05, 2004 2:36 am 
Newbie

Joined: Thu Dec 04, 2003 9:07 am
Posts: 7
Location: Johannesburg
Actually commons-logging does choose log4j if it is on the classpath. My problem was caused by having ws-commons-logging.jar (Websphere library) on the classpath (for some reason) which messed things up.

So it was ..err.. IBM's fault! Anyway using org.apache.commons.logging.log=org.apache.commons.logging.impl.Log4JCategoryLog did work for this situation when put in a commons-logging.properties file.

This may be a solution if trying to deploy to Websphere.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 05, 2004 9:01 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Poeple I know using Websphere, replaced the ws-commons-logging.jar by an appropriate commons-logging one.

IBM addressed this issue in the current or future release.

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Sat Mar 06, 2004 12:15 am 
Beginner
Beginner

Joined: Thu Feb 05, 2004 10:39 pm
Posts: 44
I am also trying to turn logging on in WebSphere for hibernate.

I have placed both the commons-loggin.properties file and log4j.properties file in my classpath but the configurations don't seem to change anything. I am still at the INFO level.

I tried replacing the ws-commons-logging.jar file with the latest commons version but get an error when I start up the built in WAS 5.0 server:

Code:
[1/3/04 22:09:54:256 CST] 4e81f9d4 SystemErr     R log4j:WARN No appenders could be found for logger (org.apache.commons.discovery.log.DiscoveryLogFactory).
[1/3/04 22:09:54:256 CST] 4e81f9d4 SystemErr     R log4j:WARN Please initialize the log4j system properly.


So, I have to put it back to work. Any ideas how to get this to work? I am trying to make this work so that I can trouble shoot a different hibernate problem I already posted about.


Top
 Profile  
 
 Post subject: websphere commons logging
PostPosted: Sun Mar 07, 2004 10:53 am 
Regular
Regular

Joined: Mon Nov 24, 2003 6:36 pm
Posts: 105
Hi, I had a PMR for this at one point with IBM> We use the "PARENT_LAST" classloader scheme, and had issues with commons-logging from websphere. By default, was5 uses PARENT_FIRST classloader, which means classloader will attempt to use was stuff first. Instead of replacing the was logging jar, just use PARENT_LAST. In addition, in order to prevent commons-logging from finding commons-logging.properties from the WAS version of the file, simply put a blank file called "commons-logging.properties" in your classpath.

We use log4j, and have no problems when we use this approach.
You will need log4j.properties on your classpath too.

Hope this helps.

James


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.