Based on parent directory - NLog config

I am using NLog in a multi-project solution. I set the filename

config file property to "${basedir}/logs/logFile.log"

, and the problem is this: a log directory is created in each main project directory, so each project has its own set of logs. I would like to have one log directory for the entire solution, so this basically means that filename

for the parent directory. How can i do this? "../${basedir}/logs/logFile.log"

doesn't seem to work, the logs are saved in the same directory.

+3


source to share


2 answers


I had a similar situation. I need the / logs / directory to be the sibling of the actual directory of my project. I found this works for me with:

fileName="${basedir}/../logs/logFile.log"

      



I am using NLog 2.1.0

+9


source


You can use for example ${specialfolder:folder=LocalApplicationData}/logs/logFile.log

. This will create a log%USERPROFILE%\AppData\Local\logs



This solution will also work on an enterprise application, as this folder has all the user rights required for the application process to write logs.

+2


source







All Articles