4
votes

I'm having trouble getting Azure Application Logging to work with my Web app. I can successfully publish and use my web app. When I go to look at the logs, however, the "application" folder is empty. I can successfully see messages I write to the console in the stdout.log files... but there's never anything in the application folder.

As for what I've tried, I've followed the steps outlined here. It seems pretty straightforward. Configure Azure to turn on Application Logging, write Trace commands in your code, and stuff should get written to the application folder in the logs. I've also tried setting Application Logging (Blob) to on, but I don't see anything written there either.

Below is a screenshot of what I have configured in Azure:

Azure Screenshot

And here's an example of me writing to Trace in code:

public class HomeController : Controller
{
    public IActionResult Index()
    {
        Trace.TraceInformation("At Home");
        return View();
    }
}

This is using ASP.NET 5/MVC 6. Note that I've tried using TraceWarning and TraceError too without luck. I've also tried turning on ALL the logging options in Azure, but that doesn't seem to do anything either.

1

1 Answers

1
votes

Trace looging doesn't work on Azure with ASP.NET 5. This is known bug

You can use HttpPlatformHandler logging into file system.

Put into your wwwroot directory web.config file:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <system.web>
    <customErrors mode="Off" />
  </system.web>
  <system.webServer>
    <handlers>
      <add
        name="httpPlatformHandler"
        path="*"
        verb="*"
        modules="httpPlatformHandler"
        resourceType="Unspecified"/>
    </handlers>
    <httpPlatform
      processPath="%DNX_PATH%"
      arguments="%DNX_ARGS%"
      stdoutLogEnabled="true"
      stdoutLogFile="..\..\LogFiles\httpplatform\httpplatform-stdout.log"
      startupTimeLimit="3600"/>
  </system.webServer>
</configuration>

Settings for loogging located here:

      stdoutLogEnabled="true"
      stdoutLogFile="..\..\LogFiles\httpplatform\httpplatform-stdout.log"

Make sure that direcotory for logging exists in you file system at Azure.

You have to use standart logging mechanism for write logs