log4net [1.2.14] - 一般故障 - 参数丢失
log4net [1.2.14] - Generic Failure - Parameter Missing
我在 log4net 错误日志中收到以下错误:
log4net:ERROR [AdoNetAppender] ErrorCode: GenericFailure. Exception while writing to database
System.IndexOutOfRangeException: An SqlParameter with ParameterName '@logId' is not contained by this SqlParameterCollection.
at System.Data.SqlClient.SqlParameterCollection.GetParameter(String parameterName)
at System.Data.Common.DbParameterCollection.System.Data.IDataParameterCollection.get_Item(String parameterName)
at log4net.Appender.AdoNetAppenderParameter.FormatValue(IDbCommand command, LoggingEvent loggingEvent)
at log4net.Appender.AdoNetAppender.SendBuffer(IDbTransaction dbTran, LoggingEvent[] events)
at log4net.Appender.AdoNetAppender.SendBuffer(LoggingEvent[] events)
这是来自 web.config 的代码:
<commandText value="INSERT INTO WebTeamAdminAppLog ([ID],[Date],[Application],[Server],[ProcessId],[Login],[Thread],[Level],[Logger],[Message],[Exception],[SessionId]) VALUES (@logId,@log_date,@app,@server,@processId,@login,@thread,@log_level,@logger,@message,@exception,@sessionid)" />
<parameter>
<parameterName value="@logId" />
<dbType value="Guid" />
<layout type="log4net.Layout.RawPropertyLayout">
<key value="logId" />
</layout>
</parameter>
不确定是什么问题,因为这段代码来自另一个将日志插入数据库的项目。它是相同的数据库,只是不同 table。另一个应用程序中log4net的版本是1.2.13.0。此外,当我单步执行调试器时,logId 值似乎设置正确。
如果你有这样的事情,请检查你的代码:
Guid id = Guid.NewGuid();
var loggingEvent = new LoggingEvent(.....)
loggingEvent.Properties["logId"] = id;
我刚找到以下 SO post。似乎正是我遇到的问题:log4net AdoNetAppender - SqlParameterCollection does not contain parameters
降级到 1.2.13 解决了我的问题。
我在 log4net 错误日志中收到以下错误:
log4net:ERROR [AdoNetAppender] ErrorCode: GenericFailure. Exception while writing to database
System.IndexOutOfRangeException: An SqlParameter with ParameterName '@logId' is not contained by this SqlParameterCollection.
at System.Data.SqlClient.SqlParameterCollection.GetParameter(String parameterName)
at System.Data.Common.DbParameterCollection.System.Data.IDataParameterCollection.get_Item(String parameterName)
at log4net.Appender.AdoNetAppenderParameter.FormatValue(IDbCommand command, LoggingEvent loggingEvent)
at log4net.Appender.AdoNetAppender.SendBuffer(IDbTransaction dbTran, LoggingEvent[] events)
at log4net.Appender.AdoNetAppender.SendBuffer(LoggingEvent[] events)
这是来自 web.config 的代码:
<commandText value="INSERT INTO WebTeamAdminAppLog ([ID],[Date],[Application],[Server],[ProcessId],[Login],[Thread],[Level],[Logger],[Message],[Exception],[SessionId]) VALUES (@logId,@log_date,@app,@server,@processId,@login,@thread,@log_level,@logger,@message,@exception,@sessionid)" />
<parameter>
<parameterName value="@logId" />
<dbType value="Guid" />
<layout type="log4net.Layout.RawPropertyLayout">
<key value="logId" />
</layout>
</parameter>
不确定是什么问题,因为这段代码来自另一个将日志插入数据库的项目。它是相同的数据库,只是不同 table。另一个应用程序中log4net的版本是1.2.13.0。此外,当我单步执行调试器时,logId 值似乎设置正确。
如果你有这样的事情,请检查你的代码:
Guid id = Guid.NewGuid();
var loggingEvent = new LoggingEvent(.....)
loggingEvent.Properties["logId"] = id;
我刚找到以下 SO post。似乎正是我遇到的问题:log4net AdoNetAppender - SqlParameterCollection does not contain parameters
降级到 1.2.13 解决了我的问题。