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.  [ 10 posts ] 
Author Message
 Post subject: watch SQL statement in a web application project
PostPosted: Sat Jul 21, 2007 6:52 am 
Regular
Regular

Joined: Tue Jun 26, 2007 11:50 am
Posts: 105
How can I watch SQL statement in a web application project. Set hibernate.show_sql property to true only work for Console application ?


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jul 21, 2007 11:08 am 
Hibernate Team
Hibernate Team

Joined: Tue Jun 13, 2006 11:29 pm
Posts: 315
Location: Calgary, Alberta, Canada
Enable log4net and messages will be logged to a log file. Please read the documentation here:
http://www.hibernate.org/hib_docs/nhibe ... on-logging

_________________
Karl Chu


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jul 22, 2007 7:54 am 
Regular
Regular

Joined: Tue Jun 26, 2007 11:50 am
Posts: 105
Thank you.
I don't understand to which log file the messages are redirected. I think I can define it in the log4net section (in web.config), but I don't find how... Could you help me, please ?
But what about this file. I'll be modified each time a sql request is sent by nhibernate ? Wouldn't it be better to have those messages in the output window while debugging ?


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jul 22, 2007 2:43 pm 
Hibernate Team
Hibernate Team

Joined: Tue Jun 13, 2006 11:29 pm
Posts: 315
Location: Calgary, Alberta, Canada
I should have said "Enable log4net and messages will be logged to a destination of your choice". Either the ConsoleAppender or the TraceAppender will send the log messages to the output window (I forgot which one is which). See log4net's documentation here:
http://logging.apache.org/log4net/relea ... mples.html

_________________
Karl Chu


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jul 22, 2007 4:03 pm 
Regular
Regular

Joined: Tue Jun 26, 2007 11:50 am
Posts: 105
I tried the ConsoleAppender, the OutputDebugStringAppender and the TraceAppender but none of them work.
Here is an extract of my config file :

<configSections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,log4net" />
</configSections>

<log4net>
<appender name="TraceAppender" type="log4net.Appender.TraceAppender">
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date [%thread] %-5level %logger [%property{NDC}] - %message%newline" />
</layout>
</appender>
</log4net>

Do I forget something ?


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jul 22, 2007 4:29 pm 
Hibernate Team
Hibernate Team

Joined: Tue Jun 13, 2006 11:29 pm
Posts: 315
Location: Calgary, Alberta, Canada
Add this after the appender:
Code:
    ...
    </appender>
    <root>
        <level value="DEBUG" />
        <appender-ref ref="TraceAppender" />
    </root>
    ...

_________________
Karl Chu


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jul 22, 2007 6:23 pm 
Regular
Regular

Joined: Tue Jun 26, 2007 11:50 am
Posts: 105
Sorry, but it doesn't chnage the problem. What more can I do ?


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jul 22, 2007 6:36 pm 
Hibernate Team
Hibernate Team

Joined: Tue Jun 13, 2006 11:29 pm
Posts: 315
Location: Calgary, Alberta, Canada
I assume you have read the documentation for log4net, haven't you? You can find it here:
http://logging.apache.org/log4net/relea ... ction.html

The section that is specific to configuration can be found here:
http://logging.apache.org/log4net/relea ... ation.html

I suspect you have not called the static method Configure() on one of the configuration classes; most typically the XmlConfigurator class. The \second link above should have all the information you need. Please have a read through it.

_________________
Karl Chu


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jul 22, 2007 7:33 pm 
Regular
Regular

Joined: Tue Jun 26, 2007 11:50 am
Posts: 105
ok, it works. Thank you for your advices.
I'm surprised to see so many informations in the output window. Is there a way to just display the sql requests ? I read in you documentation that we can use filter. Which sort of filter you would use to reduce the number of informations display ? Which informations do you find usefull ?
For example, I get this :
NHibernate.Impl.SessionImpl: 2007-07-23 01:18:36,227 [11] DEBUG NHibernate.Impl.SessionImpl [(null)] - reading row
NHibernate.Type.Int32Type: 2007-07-23 01:18:36,227 [11] DEBUG NHibernate.Type.Int32Type [(null)] - returning '8' as column: Nutriment2_3_
NHibernate.Impl.SessionImpl: 2007-07-23 01:18:36,227 [11] DEBUG NHibernate.Impl.SessionImpl [(null)] - loading [Nutriment#8]
NHibernate.Impl.SessionImpl: 2007-07-23 01:18:36,227 [11] DEBUG NHibernate.Impl.SessionImpl [(null)] - attempting to resolve [Nutriment#8]
NHibernate.Impl.SessionImpl: 2007-07-23 01:18:36,227 [11] DEBUG NHibernate.Impl.SessionImpl [(null)] - resolved object in session cache [MyClassesTest.Nutriment#8]
Would you keep such informations ?


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jul 22, 2007 7:47 pm 
Hibernate Team
Hibernate Team

Joined: Tue Jun 13, 2006 11:29 pm
Posts: 315
Location: Calgary, Alberta, Canada
I am not familiar with log4net filters myself, so I don't have much advice to offer except to tell you to have a look at the docs; specifically here:
http://logging.apache.org/log4net/relea ... ml#filters

_________________
Karl Chu


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