My app creates a log for the application itself, so record when it was activated, and what happened at an application level.
The application is centered around 'profiles' - the user loads a profile which tells the application where/when/what/how. So I also want to create a log for each profile, to record the progress each time the profile is run.
No problems so far... except that I want the profile log to be stored alongside the profile itself, so this means I need to configure NLog dynamically, so I can tell it the fileTarget path at runtime.
However, I was also wanting to store the standard layouts I want to use, as variables in NLog.config; this seems to be a common enough approach from what I have read.
However, at the following line
fileTarget.Layout = "${myLayout}"
...I get an ArgumentException:
LayoutRenderer cannot be found: 'myLayout'
At the moment, my layout variable is simply:
<variable name="myLayout" value="${message}" />
Is it a case that you can't use variables to specify layout through the API? I would be surprised if that was the case. Or have I gone wrong somewhere?
The solution is simple enough - I can populate fileTarget.Layout
with a manually-specified layout, but nevertheless, I'm keen to find out if Plan A could work.