In a .net-core console app, I'm using Serilog file sink for logging. For configuration, I provide a file path (F:\\log.json
) for file sink to write logs. Assume that the specified file is read-only, I expect Serilog file sink to write logs on a new file (e.g. F:\\log_1.json
) but Serilog file sink actually give up on writing the log to file.
Here is my sample code. I simplified my code to demonstrate the issue.
class Program
{
static void Main(string[] args)
{
var logger = new LoggerConfiguration()
.MinimumLevel.Debug()
.WriteTo.File("F:\\\\log.json")
.CreateLogger();
logger.Information("Hello, stackoverflow :D");
}
}
I also tried passing shared: true
to the File
extension method, but the behavior doesn't change.
Any idea how I can achieve that?