Why is the ${basedir} NLog configuration not working?

后端 未结 1 1002
旧时难觅i
旧时难觅i 2021-01-17 22:41

Why I cannot use ${basedir} nlog.config in my production server? If I use fileName=\"${basedir}/logs/${shortdate}.log\", nlog does not log the message info, but

相关标签:
1条回答
  • 2021-01-17 23:34

    This issue is related to file permission. Short story: the user that the web application is running as does not have permission to write the log files.

    Depending on the version of .NET and the version of IIS, there are a variety of users that it could be.

    For IIS 6, I would say that the web application is running as the NETWORK SERVICE account.

    Therefore, you will need to grant this user permission to write/modify the logs folder (which I presume is a sub-folder of the web root). If you want the logs folder to be created automatically by NLog, you'll need to grant these permissions to the web root instead.

    0 讨论(0)
提交回复
热议问题