How can I set the target
in the NLog.config file to create the log file in the user app data directory?
Below is the desired location of the file.
C:\Users\userid\AppData\Local...\LogFile.txt
I tried setting the fileName
in the following ways without any success.
target name="logfile" xsi:type="File" fileName="%APPDATA%/.../LogFile.txt"
target name="logfile" xsi:type="File" fileName="${APPDATA}/.../LogFile.txt"
target name="logfile" xsi:type="File" fileName="${%APPDATA%}/.../LogFile.txt"
You can achieve that by creating a target like this:
<target name="logfile" xsi:type="File"
fileName="${specialfolder:folder=ApplicationData}/LogFile.txt"/>
The documentation can be found here.
I hope this helps.