我已经在我的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
我使用了${basedir}
,并将internalLogFile和fileName的值更改为
internalLogFile="${basedir}/internal_logs/internallog.txt">
和
fileName="${basedir}/logs/${shortdate}_logfile.txt"
现在我可以访问项目中bin
文件夹中的这些文件。