1
votes

Very simply issue, not certain how to fix it. I've deployed a MVC .NET application to Azure, and added the following controller.

enter image description here

Here is what my Azure diagnostic log setup looks like:

enter image description here

And for good measure, the relevant sections of my web.config:

enter image description here

My problem is that the logs aren't being written to either the Log stream or the LogFiles folder in the FTP drive given by Azure. I have two other very similar applications logging without problem - however this one refuses to log. Is there setting somewhere that would implicitly stop logging?

Note - I'm certain the log statements are being executed, as I can reach the home/index page without problem once published.

2
Have you tried setting the Level to Verbose? Does that change anything? Also, have you looked at the Live Log Stream to see if they show up there?Chris Pietschmann

2 Answers

0
votes

I believe that what you're missing here is an actual listener being configured. Try to add following code to your web.config:

<system.diagnostics>
     <trace>
       <listeners>
         <add name="WebPageTraceListener"
             type="System.Web.WebPageTraceListener,
             System.Web,
             Version=4.0.0.0,
             Culture=neutral,
             PublicKeyToken=b03f5f7f11d50a3a" />
       </listeners>
     </trace>
   </system.diagnostics>

and

<trace enabled="true" writeToDiagnosticsTrace="true" mostRecent="true" pageOutput="false" />

If I remember correctly, the default trace listener is not logging data in a manner consumable by Azure. Personally I'm using Application Insights for getting all the data, still it required me to pass a listener explicitly.

0
votes

For those looking for a solution using aspnet core 3.1, take a look at this:

https://docs.microsoft.com/en-us/aspnet/core/fundamentals/logging/?view=aspnetcore-3.1