Closed sommmen closed 2 years ago
Hi @sommmen!
Sorry for the delay in response. Like the documentation states, if you use the MSSQL sink in normal mode (WriteTo()
) then the log operation just writes into a buffer which is asynchronously written to the DB in batches in the background. I guess there would be no performance or resposibility gain in your app if you call that asynchronously. On the other hand doing so would not be a big problem either. Check out the code starting here for details: https://github.com/serilog-mssql/serilog-sinks-mssqlserver/blob/5e9dc3a5a470a35292dc80ab612c1eaac2c84fe6/src/Serilog.Sinks.MSSqlServer/Sinks/MSSqlServer/MSSqlServerSink.cs#L125
If you use the MSSQL sink in audit mode (AuditTo()
) then each log call is written to the database directly without any buffering or delay in the sink. If you call this async your app would continue executing while the log message is written to the DB but this would also defeat the purpose of the audit sink.
I hope this helps.
Hi @sommmen!
Sorry for the delay in response. Like the documentation states, if you use the MSSQL sink in normal mode (
WriteTo()
) then the log operation just writes into a buffer which is asynchronously written to the DB in batches in the background. I guess there would be no performance or resposibility gain in your app if you call that asynchronously. On the other hand doing so would not be a big problem either. Check out the code starting here for details:If you use the MSSQL sink in audit mode (
AuditTo()
) then each log call is written to the database directly without any buffering or delay in the sink. If you call this async your app would continue executing while the log message is written to the DB but this would also defeat the purpose of the audit sink.I hope this helps.
Hello @ckadluba,
Thanks for your answer - i'll be able to make an informed decision now.
Hiya,
Quick question - i'm seeing some locking happen in my app and it seems to be doing with logging. I use the following sinks:
I want to move the sinks into Serilog.Async and to keep it consistent i'm considering moving all sinks into the async package. I ofcourse could also only move File and Console to the async serilog sink and leave the MSSQL sink alone
Just a quick peer-check: Would there be any significant performance degradations in doing this? Would it be better to not put the MSSQL sink in the Async sink or would it not matter much?
Reading the docs:
I'd say there would be some overhead (given the double queueing but nothing major.