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

Update serilog to 4 and move batching to Serilog core (fixed tests) #557

Closed ckadluba closed 2 months ago

ckadluba commented 2 months ago

Fork of original PR #545 from @cancakar35 but with fixed unit tests (see individual commits).

Original PR Text:

Related issiue: https://github.com/serilog-mssql/serilog-sinks-mssqlserver/issues/543#issue-2347936892

Update Serilog v3.1.1 to 4.0.0 https://github.com/serilog/serilog/releases/tag/v4.0.0 Update Microsoft.Data.SqlClient to 5.2.1 Remove dependency Serilog.Sinks.PeriodicBatching PerioadingBatching moved to BatchingSink in serilog core. https://github.com/serilog/serilog/pull/2055

ckadluba commented 2 months ago

@cancakar35 the tests work now and I could remove the null checks.

But when I tried to test the code from the PR with the program included in samples\WorkerServiceDemo there was a problem. This little sample tries to write to a local DB using a batched and an audit sink. The table of the audit sink contained log entries but the one of the batched sink did not conain anything.

Were you able to successfully log using a batched sink with the update to Serilog 4?

cancakar35 commented 2 months ago

I tested with appconfigdemo and a new asp.net app, didn't try worker service demo. Are there any selflog or exception for worker service?

cancakar35 commented 2 months ago

I just tried with worker service demo and its working. LogEvents: serilog4

LogEventsAudit: serilog4audit

ckadluba commented 2 months ago

Thank you. Maybe it was something on my side. I'll try to find that out.

ckadluba commented 2 months ago

Okay now. Retried this on a different machine and now WorkerServiceDemo produced logs with batched and audit sink as it should. The PR can be merged.