-->
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.  [ 12 posts ] 
Author Message
 Post subject: Log4j problem
PostPosted: Thu May 27, 2004 10:44 am 
Regular
Regular

Joined: Tue May 11, 2004 9:23 am
Posts: 69
Hey,

So I got a question concerning the log4j file. I want to see the log for hibernate. I've activated the "show_sql" in hibernate.properties. But I've understood that their is another log too, by "activating" log4j file.

I've read in the documentation about logging but I don't get how to do add the log4j to the classpath. I'm working in WSAD and my log4j.properties file is in my project root.

How do I activate the logging?

(By the way in the log4j file it says..

...

## 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

...

..something about hibernate.log. Is that where the log is saved? Do I have to create that file?)


Best regs

Newman


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 27, 2004 6:30 pm 
Beginner
Beginner

Joined: Fri May 21, 2004 3:49 pm
Posts: 21
Location: Germany, Mainz
First of all you have to put your log4j.properties into your classpath, the
second step ist, to add the log4j.jar to your lib directory, and concerning
the third question you _DON'T_ have to create the file and it IS the file
your log is saved to, but perhaps for testing it would be better in your
case to use a consoleappender.

Hope that answer helps you getting on.


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 28, 2004 2:51 am 
Regular
Regular

Joined: Tue May 11, 2004 9:23 am
Posts: 69
I know that my log4j.properties file is in my classpath and my log4j1.2.8.jar is in the JavaBuildPath. I've also decommented in the log4j file so logging data should be stored there.

However, I still can't find the file on my computer. The search function doesn't find it.

Where is your hibernate.log file located?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 01, 2004 10:48 am 
Newbie

Joined: Tue May 25, 2004 11:20 am
Posts: 17
Location: Munich, Germany
Did you remove the #'s at the beginning of the lines?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 01, 2004 11:07 am 
Regular
Regular

Joined: Tue May 11, 2004 9:23 am
Posts: 69
I sure did....but didn't help. All I use know is the debugger. But I can't seem to find the Hibernate.log file...


/Newman


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 01, 2004 11:21 am 
Newbie

Joined: Tue May 25, 2004 11:20 am
Posts: 17
Location: Munich, Germany
Please post your whole log4j.properties. Maybe there problem is at an other position of the file.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 01, 2004 11:24 am 
Regular
Regular

Joined: Tue May 11, 2004 9:23 am
Posts: 69
Here it is:

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.net.sf.hibernate=info

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

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

### 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: Tue Jun 01, 2004 11:29 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
You are logging to "stdout", not to "file". Please read the log4j documentation or get help in a log4j forum.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 01, 2004 11:50 am 
Newbie

Joined: Tue May 25, 2004 11:20 am
Posts: 17
Location: Munich, Germany
try changing
Code:
log4j.logger.net.sf.hibernate=info

to
Code:
log4j.logger.net.sf.hibernate=info, file


I'm not 100% sure because I always use log4j.xml to configure it.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 01, 2004 6:07 pm 
Senior
Senior

Joined: Wed Mar 24, 2004 11:40 am
Posts: 146
Location: Indianapolis, IN, USA
Try the following in your log4j file.

Code:
# FileAppenderDebug - Debug Level File Appender
log4j.appender.FileAppenderDebug=org.apache.log4j.FileAppender
log4j.appender.FileAppenderDebug.Threshold=DEBUG
log4j.appender.FileAppenderDebug.file={$logfilePath}/default.log
log4j.appender.FileAppenderDebug.layout=org.apache.log4j.PatternLayout
log4j.appender.FileAppenderDebug.layout.ConversionPattern=%d{DATE} [Thread %5t] %-5p [%c] - %m%n


# Hibernate Debug Logger
log4j.appender.HibernateDebug=org.apache.log4j.FileAppender
log4j.appender.HibernateDebug.Threshold=DEBUG
log4j.appender.HibernateDebug.file={$logfilePath}/HibernateDebug.log
log4j.appender.HibernateDebug.layout=org.apache.log4j.PatternLayout
log4j.appender.HibernateDebug.layout.ConversionPattern=%d{DATE} [Thread %5t] %-5p [%c] - %m%n

log4j.logger.net.sf.hibernate=DEBUG, HibernateDebug
log4j.additivity.net.sf.hibernate=false


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 02, 2004 2:42 am 
Regular
Regular

Joined: Tue May 11, 2004 9:23 am
Posts: 69
Hey,

works fine with just adding this:

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


Though I'm a little suprised since it stores the same data as is in the ConsoleAppender. I though it would give more info.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 02, 2004 3:18 am 
Beginner
Beginner

Joined: Fri May 21, 2004 3:49 pm
Posts: 21
Location: Germany, Mainz
No because you defined the same
Code:
   
Posted: Tue Jun 01, 2004 10:07 pm    Post subject:
Try the following in your log4j file.

# FileAppenderDebug - Debug Level File Appender
log4j.appender.FileAppenderDebug=org.apache.log4j.FileAppender
log4j.appender.FileAppenderDebug.Threshold=DEBUG
log4j.appender.FileAppenderDebug.file={$logfilePath}/default.log
log4j.appender.FileAppenderDebug.layout=org.apache.log4j.PatternLayout
log4j.appender.FileAppenderDebug.layout.ConversionPattern=%d{DATE} [Thread %5t] %-5p [%c] - %m%n


# Hibernate Debug Logger
log4j.appender.HibernateDebug=org.apache.log4j.FileAppender
log4j.appender.HibernateDebug.Threshold=DEBUG
log4j.appender.HibernateDebug.file={$logfilePath}/HibernateDebug.log
log4j.appender.HibernateDebug.layout=org.apache.log4j.PatternLayout
log4j.appender.HibernateDebug.layout.ConversionPattern=%d{DATE} [Thread %5t] %-5p [%c] - %m%n


modis for both, if you would have defined log4j.appender.FileAppenderDebug.Threshold=DEBUG
to info like this: log4j.appender.FileAppenderDebug.Threshold=INFO
it would provide less information.

read the faq of struts for that.


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