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]