-->
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.  [ 3 posts ] 
Author Message
 Post subject: Dump nhibernate SQL output to file
PostPosted: Fri Feb 01, 2008 5:08 am 
Beginner
Beginner

Joined: Fri Aug 10, 2007 3:34 am
Posts: 44
Hello,

Is there a way to log nhibernate's SQL Query output to a file instead of
the annoing console?
I've searched the web and didn't find anything conclusive, just ways of
using log4net that were confusing.

I appreciate the help!
Thanks.


Top
 Profile  
 
 Post subject: Dump nhibernate SQL output to file
PostPosted: Fri Feb 01, 2008 7:37 am 
Senior
Senior

Joined: Thu Jun 21, 2007 8:03 am
Posts: 127
Location: UK
Hi,

I suspect using log4net is probably the easiest way.

Add a reference to log4net, and a line to your startup-code that says:
Code:
    log4net.Config.XmlConfigurator.Configure();


... then add something like this to your .config file:
Code:
<configuration>

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

    <log4net>
        <appender name="MyNhLog" type="log4net.Appender.RollingFileAppender">
            <param name="File" value="c:\MyNhLog.log"/>
            <layout type="log4net.Layout.PatternLayout">
                <conversionPattern value="%d level %message%newline" />
            </layout>
        </appender>
        <logger name="NHibernate">
            <level value="INFO" />
            <appender-ref ref="MyNhLog"/>
        </logger>
    </log4net>
    ...
</configuration>


... and that's all you should need.

Regards,
Richard


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 01, 2008 8:42 am 
Beginner
Beginner

Joined: Fri Aug 10, 2007 3:34 am
Posts: 44
It worked! Thanks alot!!


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