serilog-mssql / serilog-sinks-mssqlserver

A Serilog sink that writes events to Microsoft SQL Server and Azure SQL
Apache License 2.0
283 stars 148 forks source link

NullReferenceException in Serilog.Sinks.MSSqlServer.Output.AdditionalColumnDataGenerator.GetAdditionalColumnNameAndValue #460

Closed vzalamea closed 1 year ago

vzalamea commented 1 year ago

Bug Report / Support Request Template

upgrading from 6.0.0 to 6.1.0

Please clearly describe what the SQL Sink is doing incorrectly: NullReferenceException at Serilog.Sinks.MSSqlServer.Output.AdditionalColumnDataGenerator.GetAdditionalColumnNameAndValue

Please clearly describe the expected behavior: does not error

List the names and versions of all Serilog packages used in the project: Serilog.AspNetCore 6.1.0 Serilog.Sinks.MSSqlServer 6.1.0

Target framework and operating system:

[ X ] .NET Core 6

Provide a simple reproduction of your Serilog configuration code:


var columnOptions = new ColumnOptions
{
DisableTriggers = true,
AdditionalColumns = new Collection<SqlColumn>
{
new SqlColumn {ColumnName = "UserName", DataType = SqlDbType.NVarChar, DataLength = 64},
new SqlColumn {ColumnName = "HttpRequestMethod", DataType = SqlDbType.NVarChar, DataLength = 32},
new SqlColumn {ColumnName = "RouteTemplate", DataType = SqlDbType.NVarChar, DataLength = 128},
new SqlColumn {ColumnName = "MachineName", DataType = SqlDbType.NVarChar, DataLength = 32},
new SqlColumn {ColumnName = "ClientId", DataType = SqlDbType.NVarChar, DataLength = 24},
new SqlColumn {ColumnName = "AccountNumber", DataType = SqlDbType.NVarChar, DataLength = 24},
new SqlColumn {ColumnName = "CorrelationId", DataType = SqlDbType.NVarChar, DataLength = 128}
}
};
columnOptions.Store.Remove(StandardColumn.Properties); 
columnOptions.Store.Add(StandardColumn.LogEvent); 
>> Provide a *simple* reproduction of your Serilog configuration file, if any:

.WriteTo.MSSqlServer( Configuration.GetConnectionString("SerilogDb"), sinkOptions: new MSSqlServerSinkOptions { AutoCreateSqlTable = false, TableName = Configuration.GetValue("AppOptions:SerilogTableName"), BatchPeriod = TimeSpan.FromSeconds(5), BatchPostingLimit = 50 }, columnOptions: columnOptions, restrictedToMinimumLevel: restrictedToMinimumLevel )



>> Provide a *simple* reproduction of your application code:
ckadluba commented 1 year ago

Thank you for reporting this. This seems most likely to be a duplicate of #458. Closing this. Please follow the other issue for updates.