Skip to content

Conversation

cancakar35
Copy link
Member

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

Update serilog v3.1.1 to 4.0.0
Update Microsoft.Data.SqlClient to 5.2.1
PerioadingBatching moved to batching in serilog core.
@@ -281,6 +283,8 @@ public static class LoggerConfigurationMSSqlServerExtensions

var auditSink = auditSinkFactory.Create(connectionString, sinkOptions, formatProvider, columnOptions, logEventFormatter);

if (auditSink == null) return null;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Serilog 4 throws exception if sink is null.

@ckadluba
Copy link
Member

ckadluba commented Jul 3, 2024

Hi @cancakar35!

Thank you for your PR! Serilog 4 update was already on our list. We really appreciate your contribution! :)

@ckadluba
Copy link
Member

There is still the open question regarding the returned null on sink creation. Can you please look into this again?

@cancakar35
Copy link
Member Author

There is still the open question regarding the returned null on sink creation. Can you please look into this again?

Additional info for that lines:

In serilog 4 this line added https://github.com/serilog/serilog/blob/8c82a50711fb20c6e31ffd60b585359aeb9336ed/src/Serilog/Configuration/LoggerSinkConfiguration.cs#L69
Now its throw ArgumentNullException if the logEventSink parameter null
Releated commit : serilog/serilog@44c5e15

So, I thought it made sense to return null as before, instead of let it throw exception. I didn't see any problems with this approach in tests.

@cremor
Copy link

cremor commented Aug 29, 2024

What's blocking this PR currently?

@ckadluba
Copy link
Member

ckadluba commented Aug 29, 2024

This is my last concern with this PR #545 (comment)

We should not handle an exception and then return null on sink creation. Instead the exception should be handled by the caller.

I wanted to play with it to better understand why @cancakar35 implemented it like this but I did not yet get around to do this. Sorry for that.

@cremor if you could investigate this, I would highly appreciate this. Ideally we could just remove the exception handler but if not we should find a better solution.

@ad-eg-dk
Copy link

What's blocking this PR currently?

Microsoft.Data.SqlClient change hasn't been reverted yet.

@cancakar35
Copy link
Member Author

@ckadluba I chose this approach because the unit tests were failing when we let it throw exception. If we can change the unit tests we can remove null returning.

@ad-eg-dk Please look into this pr: #548 . If you have any problem , please open an issue.

@ckadluba
Copy link
Member

Maybe there is some mock missing. I'll look into this as soon as I can.

@ckadluba
Copy link
Member

ckadluba commented Sep 1, 2024

I have fixed the unit tests and created a new PR #557. But there are further open questions which I will handle in the new PR.

@ckadluba ckadluba closed this Sep 1, 2024
@cancakar35 cancakar35 deleted the serilog4-update branch October 3, 2024 15:57
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.

4 participants