Asp.net
Nlog沒有創建相對於網站項目的文件
我正在使用一個網站項目,我從 Nuget 添加了 Nlog,並使用了以下 NLog 配置:
<?xml version="1.0" encoding="utf-8" ?> <nlog autoReload="true" throwExceptions="true" xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <targets> <target name="logfile" xsi:type="File" fileName="log.txt" /> </targets> <rules> <logger name="*" minlevel="Info" writeTo="logfile" /> </rules> </nlog>我執行了 ProcessMonitor,它顯示 Nlog 正在嘗試在 IISExpress 文件夾而不是我的網站項目文件夾中創建 log.txt。
C:\Program Files (x86)\IIS Express\log.txt
如何讓 NLog 將我的日誌文件 ,
log.txt放在我的網站項目文件夾而不是 IISExpress 文件夾中?
我們想通了。
添加
${basedir}到文件名filename="${basedir}/log.txt"