I'm using Serilog v2.8.0 on a Xamarin application targeting iOS.
I'm configuring the logger as follows:
Log.Logger = new LoggerConfiguration().MinimumLevel.Verbose()
.Enrich.WithThreadId()
.Enrich.FromLogContext()
.Enrich.WithExceptionDetails()
.WriteTo.File(logFile, outputTemplate: "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz}[{Level:u3}][{ThreadId}]{SourceContext}-{Message:l}{NewLine:l}{Exception:l}", rollingInterval: RollingInterval.Day)
.WriteTo.NSLog(outputTemplate: "[{Level:u3}][{ThreadId}]{SourceContext}-{Message:l}{NewLine:l}{Exception:l}")
.CreateLogger();
It appears that sometimes, but not always, the the new file on the daily roll doesn't write to the filesystem. The application will be running and logging, but nothing is written out. Even swipe killing the application, in which I execute Log.CloseAndFlush() doesn't write the file out. Once I restart the application, the file is written, but previous logs for that day are obviously lost.
It appears it may be caused by the application being in the background with the file system locked when the device crosses midnight.
I've tried Log.CloseAndFlush(), but that disposes of my logger. In that case I have to reconfigure the logger and update all of my static references of the logger in my application. I would rather address the root cause and have SeriLog appropriately open the file when the file system does become available.
Any help or thoughts would be appreciated.