2
votes

I am using asp.net core with NLog, here is the NLog target config

   <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" />

When I run from Visual Studio (F5), asp.net create logs folder and generate file like above configuration.

But when I deploy to Azure Webapp by Azure DevOps, it couldn't generate log file.

Is there anyway to fix this issue?

1
what do you mean "it couldn't generate log file", did it fail with an error? Or was there no error and no log file? - Greg
Check if Nlog.config is deployed with the application. Check you have permissions. Check NLog Internal Logger. See also github.com/NLog/NLog/wiki/Logging-troubleshooting - Rolf Kristensen
NLog.config is deployed. In localhost it can generate log and log file, in Azure WebApp with DevOps deployment there is no error and no log file at all! - Ha Doan

1 Answers

0
votes

What happens if you change the NLog.config to be included in publish. Update csproj-file:

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

The special one is CopyToPublishDirectory