1.写到sqlserver的配置:

<!--保存到SQLSERVER数据库日志-->
<log4net>
<appender name="AdoNetAppender" type="log4net.Appender.AdoNetAppender">
<!--<bufferSize value="" />-->
<connectionType value="System.Data.SqlClient.SqlConnection, System.Data, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
<connectionString value="Server=localhost;UID=sa;PWD=8086;DataBase=daohang360;Max Pool Size=1000"/>
<commandText value="INSERT INTO Log VALUES ([Date],[Thread],[Level],[Logger],[Message],[Exception]) (@log_date, @thread, @log_level, @logger, @message, @exception)" />
<parameter>
<parameterName value="@log_date" />
<dbType value="DateTime" />
<layout type="log4net.Layout.RawTimeStampLayout" />
</parameter>
<parameter>
<parameterName value="@thread" />
<dbType value="String" />
<size value="" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%thread" />
</layout>
</parameter>
<parameter>
<parameterName value="@log_level" />
<dbType value="String" />
<size value="" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%level" />
</layout>
</parameter>
<parameter>
<parameterName value="@logger" />
<dbType value="String" />
<size value="" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%logger" />
</layout>
</parameter>
<parameter>
<parameterName value="@message" />
<dbType value="String" />
<size value="" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%message" />
</layout>
</parameter>
<parameter>
<parameterName value="@exception" />
<dbType value="String" />
<size value="" />
<layout type="log4net.Layout.ExceptionLayout" />
</parameter>
</appender>
<root>
<!-- Set this to "ERROR" before release -->
<!--Highest: OFF->FATAL->RROR->WARN->INFO->DEBUG->ALL :Lowest -->
<level value="ALL" />
<appender-ref ref="AdoNetAppender" />
<!-- <appender-ref ref="SmtpAppender" /> -->
<!--<appender-ref ref="FileAppender" /> -->
</root>
</log4net>
05-11 11:31