-->
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 and logging
PostPosted: Fri Mar 16, 2007 8:25 am 
Newbie

Joined: Fri Mar 16, 2007 6:04 am
Posts: 14
Hi,

I seem to have a problem configuring hibernate and the output for logging messages. For the time being, all hibernate messages appear in the standard output (System.out). I do not want this to happen, instead, I want them stored in a file (eg. hibernate.log). My log4j. properties file looks like the following:

Code:

log4j.logger.org.hibernate=ALL, db

log4j.appender.db=org.apache.log4j.RollingFileAppender
log4j.appender.db.file=${catalina.home}/logs/hibernate.log
log4j.appender.db.maxFileSize=1MB
log4j.appender.db.maxBackupIndex=25
log4j.appender.db.layout=org.apache.log4j.PatternLayout
log4j.appender.db.layout.conversionPattern=%d{MMM dd HH:mm:ss} %-5p (%F:%L) - %m%n



The log file created though, remains empty. What am I doing wrong here? Am I missing some other configuration needed?

Thanks in advance,
Argyro


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 16, 2007 8:34 am 
Newbie

Joined: Mon Jan 22, 2007 3:45 pm
Posts: 9
I don't know how it is configured with properties file but you can use this log4j.xml:

<?xml version="1.0" encoding="UTF-8" ?>

<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">

<log4j:configuration>

<!-- File Logging for deployment -->
<appender name="file" class="org.apache.log4j.RollingFileAppender">
<param name="File" value="logs/log.txt" />
<param name="Append" value="true" />
<param name="MaxFileSize" value="10MB" />
<param name="MaxBackupIndex" value="3" />
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d %-5p %.5X{sessionId} %c - %m\n" />
</layout>
</appender>

<!-- Presentation layer logging -->
<logger name="org.hibernate">
<level value="ALL" />
</logger>

<root>
<level value="WARN" />
<appender-ref ref="file" />
</root>

</log4j:configuration>


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 16, 2007 9:07 am 
Newbie

Joined: Fri Mar 16, 2007 6:04 am
Posts: 14
Thank you very much, but the problem still remains.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 16, 2007 1:59 pm 
Newbie

Joined: Mon Jan 22, 2007 3:45 pm
Posts: 9
Make sure that the log4j.xml ist the one which is used. Perhaps there are other log4j.xmls or log4j.properites in your classpath?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 16, 2007 2:18 pm 
Expert
Expert

Joined: Wed Apr 06, 2005 5:03 pm
Posts: 273
Location: Salt Lake City, Utah, USA
Make sure you have hibernate.show_sql set to false in your hibernate properties. (http://www.hibernate.org/hib_docs/v3/reference/en/html_single/#configuration-optional)

Having that set to true seems to makes sql output go to std out regardless of other logging settings.

And if you set log4j.debug to true in you system properties, log4j will output where it is loading its properties from. That may help you debug the problem.

_________________
nathan


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.