gpt4 book ai didi

c# - log4net AdoNetAppender - SqlParameterCollection 不包含参数

转载 作者:太空狗 更新时间:2023-10-29 17:45:53 25 4
gpt4 key购买 nike

在我的一个项目中我遇到了这个错误:

System.IndexOutOfRangeException: SqlParameterCollection does not contain SqlParameter with ParameterName "@log_date".
в System.Data.SqlClient.SqlParameterCollection.GetParameter(String parameterName)
в System.Data.Common.DbParameterCollection.System.Data.IDataParameterCollection.get_Item(String parameterName)
в log4net.Appender.AdoNetAppenderParameter.FormatValue(IDbCommand command, LoggingEvent loggingEvent)
в log4net.Appender.AdoNetAppender.SendBuffer(IDbTransaction dbTran, LoggingEvent[] events)
в log4net.Appender.AdoNetAppender.SendBuffer(LoggingEvent[] events)

这是 appender 配置(在其他项目中完美运行):

<appender name="AdoNetAppender" type="log4net.Appender.AdoNetAppender">
<bufferSize value="1" />
<connectionType value="System.Data.SqlClient.SqlConnection, System.Data, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<connectionString value="Data Source=*****;Initial Catalog=****;Integrated Security=SSPI" />
<commandText value="INSERT INTO [LogsDB].[dbo].[Logs] ([Date],[Thread],[Level],[Logger],[Message],[Exception]) VALUES (@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="@exception" />
<dbType value="String" />
<size value="2000" />
<layout type="log4net.Layout.ExceptionLayout" />
</parameter>
</appender>

如果有人遇到这个问题,我将非常感谢您的帮助

最佳答案

安装包 Log4net - 版本 2.0.3

为我工作(有同样的问题)

关于c# - log4net AdoNetAppender - SqlParameterCollection 不包含参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33696604/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com