I am trying to set up a logging system that adds log files to subfolders based on the year. However I've been unable to programmatically specify the year. I can hardcode it and it works fine, but I would like to be able to specify it programmatically. When I do this, ASP.Net takes it as a literal value and either creates a folder based on that literal string, or it doesn't do anything because the string contains characters that can't exist (or can't start) a folder name, such as the example I'm showing below. Is there a way to do this or am I stuck with hardcoding?
"Serilog":
{
"MinimumLevel":
{
"Default": "Debug",
"Override":
{
"Microsoft": "Information",
"System": "Information"
}
},
"WriteTo":
[
{
"Name": "Console",
"Args":
{
"outputTemplate": "[{Timestamp:HH:mm:ss} {Level:u3}] {Message:lj}{NewLine}{Exception}"
}
},
{
"Name": "Logger","Args":
{
"configureLogger":
{
"WriteTo":
[
{
"Name": "File",
"Args":
{
"path": "C:/data/Logs/ErrorLogs/{Date:yyyy}/errorlog_.log",
"rollingInterval": "Day",
"retainedFileCountLimit": null,
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level:u3}] {Message:lj}{NewLine}{Exception}"
}
}
],
"Filter":
[
{
"Name": "ByIncludingOnly",
"Args":
{
"expression": "(@Level = 'Error' or @Level = 'Fatal')"
}
}
]
}
}
},
...