nreco / logging

Generic file logger for .NET Core (FileLoggerProvider) with minimal dependencies
MIT License
284 stars 56 forks source link

Rolling file with Date variable from appsettings.json #21

Closed galdaka closed 2 years ago

galdaka commented 3 years ago

¿Is posible configure name of file with Date?

"File": {
  "Path": "logs\\app_{0:yyyy}-{0:MM}-{0:dd}.log",
  "Append": "True",
  "FileSizeLimitBytes": 1048576, // use to activate rolling file behaviour 1MB
  "MaxRollingFiles": 5 // use to specify max number of log files
}
VitaliyMF commented 3 years ago

To resolve 'variables' in the log file name you need to define FormatLogFileNamehandler in Startup.cs: https://github.com/nreco/logging#change-log-file-name-on-the-fly

galdaka commented 3 years ago

Hi,

What I intend is to unite the two characteristics: Rolling and custom format name in specific folder (Defined in appsettings.json). Is posible?

Thanks in advance,

VitaliyMF commented 3 years ago

What I intend is to unite the two characteristics: Rolling and custom format name in specific folder (Defined in appsettings.json). Is posible?

This combination should work just fine.