Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 5 commits into from
Sep 4, 2024

Conversation

ckadluba
Copy link
Member

@ckadluba ckadluba commented Sep 1, 2024

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

Original PR Text:

Related issiue: #543 (comment)

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. serilog/serilog#2055

cancakar35 and others added 5 commits September 1, 2024 22:37
Update serilog v3.1.1 to 4.0.0
Update Microsoft.Data.SqlClient to 5.2.1
PerioadingBatching moved to batching in serilog core.
* Removed null checks in config extensions if sink factory returns null before calling Sink() method from Serilog's LoggerSinkConfiguration or LoggerAuditSinkConfiguration. The truth is that our sink factory may not return null. If it does in production, we should let the exception happen. It happened in the tests because of a missing setup on two mocks.
* Added missing setups in tests.
Bumped major version after Serilog update from 3 to 4.
@ckadluba
Copy link
Member Author

ckadluba commented Sep 1, 2024

@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
Copy link
Member

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
Copy link
Member

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

LogEventsAudit:
serilog4audit

@ckadluba
Copy link
Member Author

ckadluba commented Sep 2, 2024

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

@ckadluba ckadluba added this pull request to the merge queue Sep 4, 2024
@ckadluba
Copy link
Member Author

ckadluba commented Sep 4, 2024

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.

Merged via the queue into serilog-mssql:dev with commit ea15c53 Sep 4, 2024
5 checks passed
@ckadluba ckadluba deleted the serilog4-update branch September 5, 2024 15:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants