NHibernate +Log4Net 解决速度慢的问题

http://kashfarooq.wordpress.com/2008/12/05/improve-the-performance-of-nhibernate-by-getting-your-log4net-settings-right/

View Code
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <configSections>
    <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,log4net-net-1.0"/>
  </configSections>
  <log4net>
    <root>
      <level value="ALL" />
      <appender-ref ref="ADONetAppender" />
    </root>
    <appender name="ADONetAppender" type="log4net.Appender.ADONetAppender">
      <bufferSize value="1" />
      <connectionType value="System.Data.SqlClient.SqlConnection, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
      <connectionString value="server=.; uid=sa; pwd=........; database=ATMSV2" />
      <commandText value="INSERT INTO Log([Date],[Thread],[Level],[RequestUrl],[Message],[Exception],[LoggerID]) VALUES (@log_date, @thread, @log_level, @RequestUrl, @message, @exception,@LoggerID)" />
      <parameter>
        <parameterName value="@log_date"/>
        <dbType value="DateTime"/>
        <layout type="log4net.Layout.RawTimeStampLayout"/>
      </parameter>
      <parameter>
        <parameterName value="@thread"/>
        <dbType value="String"/>
        <size value="255"/>
        <layout type="log4net.Layout.PatternLayout">
          <conversionPattern value="%thread"/>
        </layout>
      </parameter>
      <parameter>
        <parameterName value="@log_level"/>
        <dbType value="String"/>
        <size value="50"/>
        <layout type="log4net.Layout.PatternLayout">
          <conversionPattern value="%level"/>
        </layout>
      </parameter>     
      <parameter>
      <parameterName value="@RequestUrl"/>
      <dbType value="String"/>
      <size value="255"/>
      <layout type="ATMS.Common.HJRightLayout,ATMS.Common">
        <conversionPattern value="%RequestUrl"/>
      </layout>
      </parameter>
      <parameter>
        <parameterName value="@LoggerID"/>
        <dbType value="String"/>
        <size value="255"/>
        <layout type="ATMS.Common.HJRightLayout,ATMS.Common">
          <conversionPattern value="%LoggerID"/>
        </layout>
      </parameter>
      <parameter>
        <parameterName value="@message"/>
        <dbType value="String"/>
        <size value="4000"/>
        <layout type="ATMS.Common.HJRightLayout,ATMS.Common">
          <conversionPattern value="%Tips"/>
        </layout>
      </parameter>
      <parameter>
        <parameterName value="@exception"/>
        <dbType value="String"/>
        <size value="2000"/>
        <layout type="log4net.Layout.ExceptionLayout"/>
      </parameter>
      <filter type="log4net.Filter.LoggerMatchFilter">
        <LoggerToMatch value="NHibernate" />
        <AcceptOnMatch value="False" />
      </filter>
    </appender>
  </log4net>
</configuration>

 

posted on 2012-03-01 21:35  博览潇湘  阅读(424)  评论(0编辑  收藏  举报

导航