Azure门户上使用的Configuration NLog.config文件

问题描述 投票:0回答:1

我已经在我的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

azure asp.net-core nlog
1个回答
0
投票

我使用了${basedir},并将internalLogFile和fileName的值更改为

internalLogFile="${basedir}/internal_logs/internallog.txt">

fileName="${basedir}/logs/${shortdate}_logfile.txt"

现在我可以访问项目中bin文件夹中的这些文件。

© www.soinside.com 2019 - 2024. All rights reserved.