Setting up NHibernate SQL Logging

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <configSections>
  <!-- Others sections -->
  <section name="log4net"
           type="log4net.Config.Log4NetConfigurationSectionHandler,log4net" />
  </configSections>
  <log4net>
    <appender name="GeneralLog"
              type="log4net.Appender.RollingFileAppender">
      <file value="Logs.txt"/>
      <appendToFile value="true"/>
      <maximumFileSize value="100KB"/>
      <rollingStyle value="Size"/>
      <layout type="log4net.Layout.PatternLayout">
        <conversionPattern value="%d{HH:mm:ss} [%t] %-5p %c - %m%n"/>
      </layout>
    </appender>
    <logger name="NHibernate.SQL"
            additivity="false">
      <level value="DEBUG" />
      <appender-ref ref="GeneralLog" />
    </logger>
  </log4net>
</configuration>

and call

log4net.Config.XmlConfigurator.Configure();

from you application startup.

 

A more Official route.

Here is some HowTo from nhforge.org

Comments [0]
All comments require the approval of the site owner before being displayed.
Name
E-mail
(will show your gravatar icon)
Home page

Comment (Some html is allowed: a@href@title, b, blockquote@cite, em, i, strike, strong, sub, super, u) where the @ means "attribute." For example, you can use <a href="" title=""> or <blockquote cite="Scott">.  

Enter the code shown (prevents robots):

Live Comment Preview