Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Conditional logging by Serilog in C#

There is a Asp.Net Core project requirement that we need to log errors, warnings, information, exceptions, etc. to the streams below:

1) A SQL Server table.

2) During logging, if SQL Server database suddenly becomes unavailable, we'd like to continue logging by writing log entries to a shared network folder.

3) Again, if during logging, the shared network folder becomes unavailable, then we want to continue logging to a local folder.

Is this scenario something that Serilog (https://serilog.net/) can help us to achieve?

like image 221
Arash Avatar asked Oct 29 '25 16:10

Arash


1 Answers

No, this isn't built into the Serilog sinks you have described.

Enabling all three sinks concurrently achieves roughly the same thing - you could avoid additional latency by writing through Serilog.Sinks.Async if the file I/O is a concern.

like image 121
Nicholas Blumhardt Avatar answered Oct 31 '25 07:10

Nicholas Blumhardt