1

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?

Ruben Bartelink
  • 59,778
  • 26
  • 187
  • 249
  • 1
    I'd like to add `serilog-sinks-file` tag, but I can't create a new tag because of my reputation. I appreciate if someone create this tag. – parsa2820again Mar 30 '21 at 08:22

0 Answers0