-->
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.  [ 7 posts ] 
Author Message
 Post subject: Hibernate is not using log4j :|
PostPosted: Fri Aug 26, 2005 12:21 pm 
Beginner
Beginner

Joined: Thu Aug 18, 2005 4:34 pm
Posts: 33
Hi.

I have a log4j.properties in my class path.

Here is the contents
Code:
### direct messages to file hibernate.log ###
log4j.appender.file=org.apache.log4j.FileAppender
log4j.appender.file.File=C:\\Program Files\\WebSphere\\AppServer\\installedApps\\lithium\\BoardroomFinder.ear\\boardroom.war\\boardroom.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, file

#log4j.logger.org.hibernate=info
log4j.logger.org.hibernate=debug

### log just the SQL
log4j.logger.org.hibernate.SQL=debug

### log JDBC bind parameters ###
log4j.logger.org.hibernate.type=info
#log4j.logger.org.hibernate.type=debug

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

### log HQL parse trees
#log4j.logger.org.hibernate.hql=debug

### log cache activity ###
#log4j.logger.org.hibernate.cache=debug

### log transaction activity
#log4j.logger.org.hibernate.transaction=debug

### log JDBC resource acquisition
#log4j.logger.org.hibernate.jdbc=debug

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


I also have my servlet setup a Logger using this log4j file.

The servlet's logging's go to the file correctly.

All of Hibernate's logging ends up in my Websphere SystemOut.log.

The documentation for Hibernate says "put log4j.properties anywhere in your classpath" which I have done.

Any tips? I remember vaguely something about Websphere having it's own logging factory or some nonsense but I can't remember it and can't google something I barely remember :)

Thanks,
Greg


Top
 Profile  
 
 Post subject: commons logging
PostPosted: Fri Aug 26, 2005 12:34 pm 
Expert
Expert

Joined: Fri Jul 22, 2005 2:42 pm
Posts: 670
Location: Seattle, WA
H uses whatevel logging framework is available through commons-logging package.
You may need to tell commons-logging to use log4j, otherwise it may use JDK's logging.

Basically you need to put file commons-logging.properties that will have
org.apache.commons.logging.Log=org.apache.commons.logging.impl.Log4JCategoryLog
or
org.apache.commons.logging.LogFactory=org.apache.commons.logging.impl.Log4JCategoryLog
depends on commons-logging version first in your classpath.

And by the way: _your_ commons-logging.properties and log4j.properties should precede any other instances of commons-logging.properties and log4j.properties in _your_ classpath.

So, it is not anywhere in the classpath.

_________________
--------------
Konstantin

SourceLabs - dependable OpenSource systems


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 26, 2005 12:41 pm 
Beginner
Beginner

Joined: Thu Aug 18, 2005 4:34 pm
Posts: 33
Sorry, but it is in my classpath.

I found a thread on here that fixed it. I created a file in a "services" directory under meta-inf to force Websphere to use the log4j logging.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 26, 2005 2:13 pm 
Beginner
Beginner

Joined: Thu Aug 18, 2005 4:34 pm
Posts: 33
OK, I'm getting the hang of this.

I'm trying to get a global log file for any log4j stuff, then a file for my application logged, then a file for hibernate. I have this in log4j.properties

Code:
log4j.rootLogger=debug,default
log4j.logger.ca.gc.publiservice.boardroom=debug,boardroom
log4j.logger.org.hibernate=debug,hibernate

log4j.appender.default=org.apache.log4j.FileAppender
log4j.appender.default.File=C:\\Program Files\\WebSphere\\AppServer\\installedApps\\lithium\\BoardroomFinder.ear\\boardroom.war\\master.log
log4j.appender.default.layout=org.apache.log4j.SimpleLayout
log4j.appender.default.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n

log4j.appender.boardroom=org.apache.log4j.FileAppender
log4j.appender.boardroom.File=C:\\Program Files\\WebSphere\\AppServer\\installedApps\\lithium\\BoardroomFinder.ear\\boardroom.war\\boardroom.log
log4j.appender.boardroom.layout=org.apache.log4j.SimpleLayout
log4j.appender.boardroom.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n

log4j.appender.hibernate=org.apache.log4j.FileAppender
log4j.appender.hibernate.File=C:\\Program Files\\WebSphere\\AppServer\\installedApps\\lithium\\BoardroomFinder.ear\\boardroom.war\\hibernate.log
log4j.appender.hibernate.layout=org.apache.log4j.SimpleLayout
log4j.appender.hibernate.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n

log4j.logger.org.hibernate=debug
log4j.logger.org.hibernate.SQL=debug


The master.log works, and boardroom.log works too.

However, all the hibernate is still going to master.log, hence the hibernate isn't configured properly.

Does anyone have any hints? Have I missed something simple here?

Thanks,
Greg


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 26, 2005 3:17 pm 
Beginner
Beginner

Joined: Thu Aug 18, 2005 4:34 pm
Posts: 33
OK Fixed it, just changed the last few lines to use the alias properly.

Anyone know if I can leave out the .File property, and somehow specify this in my WEB.XML file?

Or I could leave it blank, and in the init() of my servlet, I could set to the proper values which the Servlet can lookup from the web.xml parameters i set up?


Top
 Profile  
 
 Post subject:
PostPosted: Sat Aug 27, 2005 2:37 am 
Expert
Expert

Joined: Mon Jul 04, 2005 5:19 pm
Posts: 720
gcormier wrote:
Anyone know if I can leave out the .File property, and somehow specify this in my WEB.XML file?


Nope.


Top
 Profile  
 
 Post subject: Still Interested in Looking for Answer?
PostPosted: Wed Sep 28, 2005 8:42 am 
Newbie

Joined: Mon Jul 18, 2005 10:15 am
Posts: 17
In WAS 5.x / 6.x, you can use
log4j.appender.Foo_foo.File=${was.install.root}/logs/myLogs.log

or
log4j.appender.Foo_foo.File=${log.root}/myLogs.log

and by default, the log files will be put under $WAS_HOME/logs directory. This will make it consistent when you move applicatios from your WTE, to TEST, STAGING and PROD.

Enve under Windows, no need to use "\\" and you can use "/".

HTH
-JB


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