Where can I find docker container logs for Azure App Service
Asked Answered
V

6

32

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?

Vedis answered 9/9, 2018 at 13:40 Comment(1)
Did you manage to find your app logs? What is the solution?Proudman
B
59

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

Bolingbroke answered 5/5, 2020 at 13:31 Comment(0)
H
14

I've been cursing this for a good while, and eventually found something that works for me.

First I enabled filesystem logging as per @dima_horror's answer.

Next I ran a command-line az webapp log tail --name myApp --resource-group myRg

That now seems to give me useful output (it gave me nothing prior to enabling filesystem logging).

Himmler answered 8/7, 2020 at 14:59 Comment(4)
This is frustrating that you can't simply get logs in the portal - Log stream is mixing logs from Kudu and app logs :/Negligent
I've found a coping mechanism for this. az webapp log tail ... only provides a few lines of container output. Above those lines there's a URL which, providing you're authenticated with Azure, gives you more output. So: I first tail (to get the latest URL), then paste the link into my browser. It's a workaround (and a poor experience) but it's possible. I'd love to know if/when there's an easier way.Himmler
az webapp log tail does not seem to work for linux app plans.Purgatory
It worked on my Linux app plan :)Pleuropneumonia
P
3

To add to the answers, if you're having trouble with deploying the image in your App Service and need logs for that specifically, you can get the docker logs for the provisioning phase of your container under Deployment Center, e.g.:

enter image description here

Pearsall answered 3/2, 2021 at 16:13 Comment(2)
is there any way to stream those to the Azure CLI as well?Rosemonde
Thank you so much, this had the information I needed!Effie
B
2

Have you checked the logs in container settings? I followed this guide to deploy a container to Azure web app.

Container Logs

Bealle answered 9/9, 2018 at 20:13 Comment(5)
Yes as I wrote, I do have exactly the same lines, the docker run command and that's it. No other logs from the app itself.Vedis
Do you see anything if you get the logs via CLI (learn.microsoft.com/en-us/azure/container-instances/…)?Bealle
You sure that az container commands are supposed to be used with Azure Web App? I cannot find the proper container, when I do az container list I do receive an empty array for answer. Looks like it is meant for Azure Container InstanceVedis
I came across this article (learn.microsoft.com/en-us/azure/app-service/containers/…) and thought back to your question.Bealle
Actually, I just click off then on back and now I do have much more logs but I still cannot see the Application Logs I can only see Server logsVedis
M
2

Even after enabling all the log options mentioned in the answers, I am facing same issue as that of Yorro mentioned. There is no log coming from application to understand why the application is not starting up in the web app. Such as waste of time. The same image works locally(standalone) but does not startup in webapp. Developer has no choice but to try his luck imagining all sort of options.

2023-05-31T01:58:52.713Z ERROR - Container 78cacfab for site xxx-dev has exited, failing site start
2023-05-31T01:58:52.722Z ERROR - Container 78cacfab didn't respond to HTTP pings on port: 8098, failing site start. See container logs for debugging.
2023-05-31T01:58:58.662Z INFO  - Stopping site xxx-dev because it failed during startup.

should be awarded for designing such a logging system.

Mersey answered 31/5, 2023 at 2:5 Comment(0)
A
1

I have the same exact issue, the App Service container logs is generic and vague. This is not the same logs that Docker shows us whenever we run a container.

17/02/2020 08:59:25.186 INFO - Site: tutorial-api - Start container succeeded. Container: f8bfa7e27680c0e9551c6157f9d1c8a73c9a3e739b4f15de8586ce52809798d3 17/02/2020 08:59:30.675 INFO - Site: tutorial-api - Application Logging (Filesystem): On 17/02/2020 08:59:44.106 INFO - Site: tutorial-api - Waiting for container to be ready 17/02/2020 08:59:49.116 INFO - Site: tutorial-api - Container has exited 17/02/2020 08:59:49.117 ERROR - Site: tutorial-api - Container could not be started 17/02/2020 08:59:49.120 INFO - Site: tutorial-api - Purging after container failed to start 17/02/2020 08:59:49.120 ERROR - Site: tutorial-api - Unable to start container. Error message: Container could not be started: tutorial-api_20

"Unable to start container, container couldn't be started"

Wow! Azure just told me every 60 seconds a minute has passed.

I understand that this is production environment, but you got to give us something!

Out of frustration, I decided to run same image in a Azure Container Instance resource, there it shows you the same detailed logs that Docker provides (see screenshot below)

enter image description here

Now that's what I'm talking about!

Using the error logs in Azure Container Instance, I found out that my App Service couldn't access the Sql Server resource (even though they are within the same resource group). I simply enabled the Sql Server resource to be accessed within the same resource group

enter image description here

Authentic answered 17/2, 2020 at 10:1 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.