Nhibernate中添加log4日志记录功能

节点<configuration>中

-------------------------
  <!--Log4net日志配置开始-->
  <configSections>
    <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,log4net" />
  </configSections>
  <log4net>
    <appender name="ConsoleAppender" type="log4net.Appender.ConsoleAppender, log4net">
      <layout type="log4net.Layout.PatternLayout, log4net">
        <param name="ConversionPattern" value="%d %p %m%n" />
      </layout>
    </appender>
    <appender name="RollingFile" type="log4net.Appender.RollingFileAppender,log4net" >
      <param name="File" value="log.txt" />
      <param name="AppendToFile" value="true" />
      <param name="DatePattern" value="yyyy.MM.dd" />
      <layout type="log4net.Layout.PatternLayout,log4net">
        <conversionPattern value="%d %p %m%n" />
      </layout>
    </appender>
    <root>
      <priority value="DEBUG" />
      <appender-ref ref="ConsoleAppender" />
    </root>
    <logger name="NHibernate" additivity="false">
      <level value="WARN"/>
      <appender-ref ref="RollingFile" />
      <appender-ref ref="ConsoleAppender" />
    </logger>
    <logger name="NHibernate.SQL" additivity="false">
      <level value="ALL"/>
      <appender-ref ref="RollingFile" />
      <appender-ref ref="ConsoleAppender" />
    </logger>
  </log4net>
  <!--Log4net日志配置结束-->

你可能感兴趣的:(Hibernate)