-->
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.  [ 8 posts ] 
Author Message
 Post subject: Logging is not working
PostPosted: Wed Dec 05, 2007 11:12 am 
Newbie

Joined: Thu Aug 09, 2007 9:50 am
Posts: 9
Hi all

I've just started using hibernate so sorry if this question is too stupid.

I want to use log4j for logging sql statements and many other hibernate messages. I've read the manual and tried to do it myself but it doesn't work.

I use hibernate 3.2, Java 1.6, and Apache Tomcat 6.

The structure of my project is something like this:

Root
--- files
--- images
--- web-inf
------ src
------ lib
------ classes

I have both "hibernate.cfg.xml" and "log4j.properties" under the WEB-INF/CLASSES directory and the "log4j.jar" library under WEB-INF/LIB.

The output of the logging should be a "hibernate.log" file but when i run the application this file is not created (The application works fine).

Any ideas? Thanks in advance!!

Aitor

P.D.: if you need more details just ask for them


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 05, 2007 12:30 pm 
Beginner
Beginner

Joined: Tue Nov 27, 2007 9:44 am
Posts: 46
Have you tried log4j.properties under WEB-INF ?

Regards,
Frank


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 05, 2007 12:55 pm 
Newbie

Joined: Thu Aug 09, 2007 9:50 am
Posts: 9
Thanks for your reply.

Yes, I've tried it but it doesn't work yet...


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 05, 2007 1:08 pm 
Beginner
Beginner

Joined: Tue Nov 27, 2007 9:44 am
Posts: 46
Can you post your log4j.properties file?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 05, 2007 1:36 pm 
Newbie

Joined: Wed Dec 05, 2007 1:30 pm
Posts: 5
Try adding the following to your hibernate properties OR your configuration file (hibernate.cfg.xml or datasource if using Spring):

hibernate.show_sql=true
hibernate.format_sql=true

Bill


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 10, 2007 6:53 am 
Newbie

Joined: Thu Aug 09, 2007 9:50 am
Posts: 9
First of all thank you very much for your replies. I have been on holidays these days so sorry because I couldn't reply earlier.

stbill79: I have both options added to my "hibernate.cfg.xml" file.

AlmGhandi: here is my "log4j.properties" file. I would like to send my log messages to a "hibernate.log" file. However at this moment they are only sent to a "stdout_20071210.log" file at "apache_home/logs".


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=warn, stdout

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

### log HQL query parser activity
log4j.logger.org.hibernate.hql.ast.AST=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



Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 10, 2007 7:07 am 
Beginner
Beginner

Joined: Tue Nov 27, 2007 9:44 am
Posts: 46
Quote:
### set log levels - for more verbose logging change 'info' to 'debug' ###
log4j.rootLogger=warn, stdout


Try changing that second line to:
Code:
log4j.rootLogger=warn, stdout, file


Regards,
Frank


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 10, 2007 7:22 am 
Newbie

Joined: Thu Aug 09, 2007 9:50 am
Posts: 9
Thanks AlmGhandi! It works!

Regards


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