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

MSSqlServerSink can no longer be used in PeriodicBatchingSink constructor #566

Closed SandstromErik closed 1 month ago

SandstromErik commented 2 months ago

I tried to change version from 6.6.1 to 7.0.0 but now MSSqlServerSink can no longer be used in PeriodicBatchingSink constructor. image

This is becasue IBatchedLogEventSink is ambiguous and has different namespaces in MSSqlServerSink and PeriodicBatchingSink. image

I use the latest version of Serilog and Serilog.Sinks.PeriodicBatching so I can not upgrade those. Do I need to install another package?

List the names and versions of all Serilog packages used in the project:

Target framework and operating system:

.NET 8 OS: Windows 11

cancakar35 commented 2 months ago

Hi @SandstromErik , Can you explain your problem a bit more? What is the reason for using PeriodicBatching Sink. As a reminder MSSqlServer sink supports batching by default.

mjbernot commented 2 months ago

I am having similar issues with version 7. I had to rollback to version 6 version 7 seems to remove PeriodicBatching

image

cancakar35 commented 2 months ago

version 7 seems to remove PeriodicBatching

Yes, Serilog.Sinks.PeriodicBatching dependency removed from MsSqlServer package. It's now using native BatchingSink.

From Serilog.Sinks.PeriodicBatching repository:

Serilog 4.x and later versions support batching natively. New projects should use Serilog's IBatchedLogEventSink and WriteTo.Sink(IBatchedLogEventSink), not this package which is now only maintained for compatibility reasons.

a-dam-berger commented 2 months ago

version 7 seems to remove PeriodicBatching

Yes, Serilog.Sinks.PeriodicBatching dependency removed from MsSqlServer package. It's now using native BatchingSink.

From Serilog.Sinks.PeriodicBatching repository:

Serilog 4.x and later versions support batching natively. New projects should use Serilog's IBatchedLogEventSink and WriteTo.Sink(IBatchedLogEventSink), not this package which is now only maintained for compatibility reasons.

The current build of Serilog.Sinks.MSSqlServer 7.0.0 fails to launch properly when deployed in production for .NET 8 without including the Serilog.Sinks.PeriodicBatching repository. Something inside this build is still referencing that old library and thus requires the package to be manually added to ensure the application doesn't crash. This update to version 7 crashed multiple .NET 8 applications of mine for this reason. Can you please fix this?

ckadluba commented 2 months ago

@a-dam-berger you are probably facing the same issue as another user reported as #564. MSSQL sink 7.0.0 does not have any reference to Serilog.PeriodicBatching but somewhere in the prod environment some old Serilog assembly from a previous deployment was still lying around causing the problem. After the user cleaned this up, the problem was gone.