I am trying to set NLog in ASP.NET Core project in a way that it would read the date ONCE and then create a file target based on that date. This is what I have:
<variable name ="CurrentDate" value="${longdate}"/>
<targets>
<target name="MyApp" xsi:type="File"
fileName="${specialfolder:folder=ApplicationData}/MyApp/${CurrentDate}_MyApp.log"
layout="${longdate}|${level:uppercase=true}|${message}"
deleteOldFileOnStartup="false"/>
</targets>
However what I've observed is that every time application log occurs, NLog will create a new file based on the time log happened which creates a massive clutter in the target directory.
I would like this "CurrentDate" variable that I am using to be read only once when application starts so that I would have a separate log for each time the application starts.
Any ideas how this could be done?