Asp.net core 使用NLog与Azure Devops进行日志记录

Asp.net core 使用NLog与Azure Devops进行日志记录,asp.net-core,azure-devops,nlog,azure-web-app-service,Asp.net Core,Azure Devops,Nlog,Azure Web App Service,我将asp.net内核与NLog一起使用,下面是NLog目标配置 <target name="file" xsi:type="File" layout="${longdate} ${logger} ${message}${exception:format=ToString}" fileName="${basedir}/logs/logfile-${shortdate}.txt" keepFileOpen="true" e

我将asp.net内核与NLog一起使用,下面是NLog目标配置

   <target name="file" xsi:type="File"
        layout="${longdate} ${logger} ${message}${exception:format=ToString}"
        fileName="${basedir}/logs/logfile-${shortdate}.txt"
        keepFileOpen="true"
        encoding="utf-8" />

   <target xsi:type="Null" name="blackhole" />

当我从Visual Studio(F5)运行时,asp.net将创建日志文件夹,并生成与上述配置类似的文件

但当我通过Azure DevOps部署到Azure Webapp时,它无法生成日志文件


是否仍有解决此问题的方法?

如果将NLog.config更改为包含在发布中,会发生什么情况。更新csproj文件:

<None Update="nlog.config">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
      <CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</None>

保存最新
保存最新

特别的一个是
CopyToPublishDirectory

你说的“它不能生成日志文件”是什么意思,它失败了吗?或者没有错误且没有日志文件?检查Nlog.config是否与应用程序一起部署。检查您是否有权限。检查NLog内部记录器。另请参见部署了NLog.config。在localhost中,它可以生成日志和日志文件,在带有DevOps部署的Azure WebApp中,根本没有错误和日志文件!