配置节选:
<!-- Define Sqlserver OperationLog-->
<appender name="DBAppender" type="log4net.Appender.AdoNetAppender">
<filter type="log4net.Filter.LevelRangeFilter">
<levelMin value="INFO" />
<levelMax value="INFO" />
</filter>
<bufferSize value="30" />
<connectionType value="System.Data.SqlClient.SqlConnection, System.Data, Culture=neutral" />
<connectionString value="data source=127.0.0.1;initial catalog=taishandb;User ID=disp;Password=disp" />
<commandText value="INSERT INTO [taishandb].[dbo].DWSOperationLog ([OpTime],[Msg]) VALUES (@log_date, @msg)" />
<parameter>
<parameterName value="@log_date" />
<dbType value="DateTime" />
<layout type="log4net.Layout.PatternLayout" value="%date{yyyy'-'MM'-'dd HH':'mm':'ss'.'fff}" />
</parameter>
<parameter>
<parameterName value="@msg" />
<dbType value="String" />
<size value="200" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%message" />
</layout>
</parameter>
</appender>
首先测试了写文件均是可写的,但是一旦连接上数据库就无法写入值了,数据库连接字符串没问题的,因为我用sql类库写过。想请问各位这到底怎么来解决让日志信息写入到数据库里?