Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 991
Benoit Patra Avatar asked Sep 09 '18 13:09

Benoit Patra


People also ask

How do I find app service logs in Azure?

Log detailed errors To save the error page or failed request tracing for Windows apps in the Azure portal, navigate to your app and select App Service logs. Under Detailed Error Logging or Failed Request Tracing, select On, then select Save.

Where are Docker logs stored?

Where Are Docker Logs Stored By Default? The logging driver enables you to choose how and where to ship your data. The default logging driver as I mentioned above is a JSON file located on the local disk of your Docker host: /var/lib/docker/containers/[container-id]/[container-id]-json.


1 Answers

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

like image 57
dima_horror Avatar answered Oct 06 '22 04:10

dima_horror