在 Azure 门户上使用的配置 NLog.config 文件
Configuration NLog.config file for using on Azure portal
我在我的 Web 应用程序中应用了 ASP.NET 核心 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
文件夹中访问这些文件。
我在我的 Web 应用程序中应用了 ASP.NET 核心 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
文件夹中访问这些文件。