Search code examples
xmlconfigdesktopnlog

change ${basedir} to reference desktop in NLog.config


I need to find a way to reference a directory on the desktop in the NLog.config file. Currently the NLog target is set to:

fileName="${basedir}/Daily Logs/TGTLogFile${date:format=yyyyMMdd}.txt"

I need it to point to ...Desktop/Daily Logs/TGTLogFile${date:format=yyyyMMdd}.txt

It can't be a static string referencing my user folder, as this application is used on multiple computers.

Any help with this would be greatly appreciated.


Solution

  • There is a special folder layout renderer:

    use it instead of ${basedir}:

    fileName="${specialfolder:folder=DesktopDirectory}/Daily Logs/TGTLogFile${date:format=yyyyMMdd}.txt"
    

    See docs of ${specialfolder} and list of all renderers