I have an Azure Pipeline which deploys my application to an Azure App Service.
My Application is connected to a Key Vault, and in the Key Vault is registered my connection string for my database.
In local, I can communicate with the database but not with the Key Vault I admit it's because of the ActiveDirectory registeration and I don't really need to access it in local. Everything else works properly.
But after the deployment, I can't test my application. I always got 404 error for the Swagger.
I'm almost sure that I'm getting an error while connecting to the Key Vault, so I need to be able to see the error logs of my application. Unfortunately I can't see them.
What I've tried to do is the following :
I've added this piece of code to the public static IHostBuilder CreateHostBuilder(string[] args)
method of the program.cs
:
Host.CreateDefaultBuilder(args)
.ConfigureLogging(logging => logging.AddAzureWebAppDiagnostics())
.ConfigureServices(serviceCollection => serviceCollection
.Configure<AzureFileLoggerOptions>(options =>
{
options.FileName = "azure-diagnostics-";
options.FileSizeLimit = 50 * 1024;
options.RetainedFileCountLimit = 5;
})
.Configure<AzureBlobLoggerOptions>(options =>
{
options.BlobName = "log.txt";
}))
But when I go to the kudu of my App Service, I can't find any logs which talks about an exception in my code. And I have no "log.txt" or "azure-diagnostics-*" file.
How can I see a possible exception on an Azure App Service ?
CodePudding user response:
For viewing the App Service logs, first enable it in the App Service logs
menu of the Azure App Service.
Once you enable the App Service Logs
, select the Log Stream
and you will be able to see the logs.
CodePudding user response:
To see the logs/log files of the Azure Web App Service, need to do few settings which are the following below:
- Navigate to the App Service in Azure > App Service Logs under Monitoring section > switch on the few settings as shown in below screenshot:
Now, Click on "Save" button to save the changes.
- After a few seconds, the "Web server logging" is enabled for the App Service.
- Go to FileZilla and Login with your azure app service credentials and traverse to root folder of the App Service
Run/Browse the application now.
Refresh the Log files folder in File Zilla and there is http folder created along with RawLogs sub folder inside it.
There are some tools to read the log file data in a readable format like Log browsers as the log file contains the browser name, request details in columns format and values of the request details, error information etc..,