我用的是Oracle9i,应用程序app.config的配置如下"
<configuration>
<!-- Add this element -->
<configSections>
<section name="hibernate-configuration" type="NHibernate.Cfg.ConfigurationSectionHandler, NHibernate" />
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,log4net" />
</configSections>
<!-- Add this element -->
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2" >
<!--<session-factory>
<property name="dialect">NHibernate.Dialect.MsSql2000Dialect</property>
<property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
<property name="connection.connection_string">Server=BOCO-Terry\DATA;initial catalog=NHibernate;Integrated Security=true</property>
</session-factory>-->
<session-factory>
<property name="dialect">NHibernate.Dialect.OracleDialect</property>
<property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
<property name="connection.connection_string">user id=jkpt;data source=jkorasvr;password=designer;</property>
<property name="connection.isolation" >ReadCommitted</property>
<property name="show_sql">true</property>
</session-factory>
</hibernate-configuration>
<log4net>
<appender name="ConsoleAppender" type="log4net.Appender.ConsoleAppender" >
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date [%thread] %-5level %logger [%ndc] - %message%newline" />
</layout>
</appender>
<root>
<level value="ALL" />
<appender-ref ref="ConsoleAppender" />
</root>
</log4net>
<!-- Leave the system.web section unchanged -->
<system.web>
</system.web>
</configuration>
<!-- Add this element -->
<configSections>
<section name="hibernate-configuration" type="NHibernate.Cfg.ConfigurationSectionHandler, NHibernate" />
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,log4net" />
</configSections>
<!-- Add this element -->
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2" >
<!--<session-factory>
<property name="dialect">NHibernate.Dialect.MsSql2000Dialect</property>
<property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
<property name="connection.connection_string">Server=BOCO-Terry\DATA;initial catalog=NHibernate;Integrated Security=true</property>
</session-factory>-->
<session-factory>
<property name="dialect">NHibernate.Dialect.OracleDialect</property>
<property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
<property name="connection.connection_string">user id=jkpt;data source=jkorasvr;password=designer;</property>
<property name="connection.isolation" >ReadCommitted</property>
<property name="show_sql">true</property>
</session-factory>
</hibernate-configuration>
<log4net>
<appender name="ConsoleAppender" type="log4net.Appender.ConsoleAppender" >
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date [%thread] %-5level %logger [%ndc] - %message%newline" />
</layout>
</appender>
<root>
<level value="ALL" />
<appender-ref ref="ConsoleAppender" />
</root>
</log4net>
<!-- Leave the system.web section unchanged -->
<system.web>
</system.web>
</configuration>
其中把show_sql设置成true,就能在控制台看到调试的结果,即控制台下的调试配置.
log4net节点,不是必须的,这个是用在写日志配置的.