I am using Serilog as a logger for my program. Trying to make Rolling interval files that append the yyyymmdd date to each file.
The code below is exactly what I have used the entire time and it worked for a good 4-5 days of testing and developing my UWP app further. Then I think my app started creating multiple files with the same date titling them logs-yyyymmdd_01, logs-yyyymmdd_02, etc.
This is in the MainPageViewModel Constructor
Log.Logger = new LoggerConfiguration().MinimumLevel.Debug()
.WriteTo.File(this.GetFile("logs-"), rollingInterval: RollingInterval.Day)
.CreateLogger();
public string GetFile(String FileName)
{
string s = ApplicationData.Current.LocalFolder.Path;
return s + "\\" + FileName;
}
I have the suspicion that it is calling the constructor multiple times and that might be part of the issue. But the rolling interval should only create a new file when its a new day right? Because when the app is launched multiple times, it used to use whatever file corresponded to todays date. So I either need a way to make the Log.Logger static so that it is universal, or a way to make it use only the one file. Any help would be much appreciated