-->
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.cfg.xml Log LEVEL
PostPosted: Thu Feb 07, 2008 10:39 am 
Beginner
Beginner

Joined: Tue Aug 29, 2006 8:08 am
Posts: 34
Hibernate version: 3.2.5ga

Hello, I need to get rid of al INFO messages whenever I run my apps.
Is there anyway, thru the hibernate.cfg.xml, to set the Log LEVEL so
that only ERROR messages arises ?

Tnx in advance.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 07, 2008 11:33 am 
Beginner
Beginner

Joined: Mon Nov 19, 2007 4:40 pm
Posts: 46
There are many ways... you might refer to the log4j manual for this...

One way is explicit:

Code:
   
<logger name="org.hibernate" additivity="false">
   <level value="error" />
   <appender-ref ref="STDOUT" />
</logger>


Or, you can do what I do and have the root set to Error and turn on debug only where you need it..

Code:
   
<logger name="my.path.some.class" additivity="false">
   <level value="debug" />
   <appender-ref ref="STDOUT" />
</logger>
<root>
   <level value="ERROR"></level>
</root>


Top
 Profile  
 
 Post subject: not working
PostPosted: Fri Feb 08, 2008 8:10 am 
Beginner
Beginner

Joined: Tue Aug 29, 2006 8:08 am
Posts: 34
sounded quite good but it does not work.
Into the body <session-factory> <session-factory/> I have only nodes <property> and
<mapping>. And if a I add the node you suggested me:

<logger name="logger" additivity="false">
<level value="error" />
<appender-ref ref="STDOUT" />
</logger>


i get the error

Caused by: org.hibernate.MappingException: invalid configuration
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1369)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1310)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1296)
at com.s21sec.polite.simpleserveur.HibernateUtil.<clinit>(HibernateUtil.java:14)
... 1 more
Caused by: org.xml.sax.SAXParseException: Element type "logger" must be declared.
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:236).


Then I tried several combinations, like write the node as a property instead of logger, put
it outside the <session-factory> node and none worked.

please help.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 08, 2008 8:30 am 
Beginner
Beginner

Joined: Mon Nov 19, 2007 4:40 pm
Posts: 46
that configuration is for your log4j.xml file and has nothing to do with hibernate.

Somewhere in your classpath, you need to include the log4j.xml file (with its dtd) and setup the configuration i showed you.

I strongly suggest you visit http://logging.apache.org/ and learn about log4j.


Top
 Profile  
 
 Post subject: Who determines log4j loggs ?
PostPosted: Fri Nov 07, 2008 1:21 pm 
Beginner
Beginner

Joined: Tue Aug 29, 2006 8:08 am
Posts: 34
I mean, all i have is an hibernate3.jar in my classpath and some others like commons-login.jar and so; but no log4j.jar at all (may be implicit). All I got
is an hibernate.cfg.xml in my cp ant then i launch my app
with this :

$JAVA_HOME/bin/java -Dhibernate.bytecode.use_reflection_optimizer=false
-Xmx512M -cp $BASEDIR/conf/:$CLASSPATH \
-Djava.security.policy=${BASEDIR}/con/security.policy\
-Djava.net.preferIPv4Stack=true\
-Dlog4j.logger.org.hibernate=ERROR\


In the conf directory where I have my hibernate.cfg.xml, I also added
the log4j.xml which follows :

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">

<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
<appender name="console" class="org.apache.log4j.ConsoleAppender">
<param name="Target" value="System.out"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%-5p %c{1} - %m%n"/>
</layout>
</appender>

<root>
<priority value ="error" />
<appender-ref ref="console" />
</root>

</log4j:configuration>


After all, I still get those annoying messages INFO : whatever ........

do not know what else to try.


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.