-
Notifications
You must be signed in to change notification settings - Fork 64
Open
Labels
Description
This is related to #5, but not exactly.
Here is my NReco.Logging registration with .NET DI:
services.AddLogging(loggingBuilder => {
loggingBuilder.AddFile("Logs\\app_{0:yyyy}-{0:MM}-{0:dd}.log", fileLoggerOpts => {
fileLoggerOpts.FormatLogFileName = getLogFileName;
fileLoggerOpts.FileSizeLimitBytes = 1 * 1024 * 1024; // 1MB
fileLoggerOpts.MaxRollingFiles = 10;
fileLoggerOpts.UseUtcTimestamp = true;
});
})
<...>
// callback for FormatLogFileName
static String getLogFileName(String fName) {
// cache current file name in static property:
LogFilePath = String.Format(fName, DateTime.UtcNow);
return LogFilePath;
}Everything works ok with one exception: I loose current file name tracking when log file is rolled. By looking in Logs directory, I see that file names are appended with rolling index:

And I have no idea how to access this index so I reference to actual current file in LogFilePath property. Any ideas?