【发布时间】:2020-04-18 22:50:32
【问题描述】:
我在我的 Web 应用程序中应用了 ASP.NET core 3.1,并使用 NLog 进行日志记录。
在本地主机中,我像这样设置 internalLogFile 和 fileName
internalLogFile="E:\Archives\Projects\Alpha\Alpha.Web.App\internal_logs\internallog.txt"
fileName="E:/Archives/Projects/Alpha/Alpha.Web.App/logs/${shortdate}_logfile.txt"
在 nlog.config 文件中。如何设置在 Azure 中使用的路径?
<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
autoReload="true"
internalLogLevel="Trace"
internalLogFile="E:\Archives\Projects\Alpha\Alpha.Web.App\internal_logs\internallog.txt">
<targets>
<target name="logfile" xsi:type="File"
fileName="E:/Archives/Projects/Alpha/Alpha.Web.App/logs/${shortdate}_logfile.txt"
layout="${longdate} ${level:uppercase=true} ${message}"/>
</targets>
<rules>
<logger name="*" minlevel="Debug" writeTo="logfile" />
</rules>
</nlog>
nlog.config 文件在此路径中:
https://{appname}.scm.azurewebsites.net/dev/wwwroot/nlog.config
【问题讨论】:
-
不要指定绝对路径。使用相对路径“logs\allLogs.csv”。然后从 Cloud Explorer (VS2019) 或 Server Explorer (VS2017) 中,您可以在 App Service 中找到该文件夹。
标签: azure asp.net-core nlog