Search code examples
c#azuredockerazure-web-app-serviceazure-web-app-for-containers

Where can I find docker container logs for Azure App Service


I do have a Docker container running a .net core 2 app.

The logging is configured using this code in Program.cs

public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
    WebHost.CreateDefaultBuilder(args)
        .ConfigureLogging((hostingContext, logging) =>
        {
            logging.AddConfiguration(hostingContext.Configuration.GetSection("Logging"));
            logging.AddConsole();
            logging.AddDebug();
        })
        .UseStartup<Startup>();

and the appsettings.json file

{
  "Logging": {
    "LogLevel": {
      "Default": "Information"
    }
  },
}

Logging seems to be Ok, when running Kestrel directly, I can see the logs in the terminal. Same thing, when containerized: the command docker logs shows what I want.

Troubles arise in production, when run in as a container in Azure Web App. I cannot find any consistent docker logs.

I made attempts to visit the Log file via FTP or via the url https://[mysite].scm.azurewebsites.net/api/logs/docker the log files are almost empty for example, https://[mysite].scm.azurewebsites.net/api/vfs/LogFiles/2018_09_09_RD0003FF74F63E_docker.log, only container starting lines are present enter image description here

Also I do have the same lines in the usual portal interface.

The question is: do docker logs are automatically output in docker.log files in Azure Web App? Is there something that I am missing?


Solution

  • Firstly you need to enable container logs

    [App Service] -> Monitoring -> App Service logs

    app service logs in monitoring for app service

    Then you can see container logs in [App Service] -> Monitoring -> Log stream

    view container logs in log stream

    UPD

    Also you can find logs in KUDU enter image description here

    Then "Current Docker Logs"

    enter image description here