stdout log files are empty in azure web service - azure

I have created an azure web service app used for testing purposes and run into a .Net / http issue (500.30). Ive looked into a lot of troubleshooting but nothing has worked or pointed me in the right direction.
It seems to get more info on the issue, I can use the stdout logs in the Azure app service through Kudu. This has been configured this and the files it creates are blank? Has anyone encountered this before?
What have I did, I set it up in the web.config file setting the stdlog to true but this creates the files with no info. I then removed the inprocess=hosting section as I read this fixed it for others but no joy.
Any pointers in the right direction would be appreciated

HTTP Error 500.30, The log file is created but empty - This kind of scenario is trapped by the SDK when publishing a self-contained app.
There is a term called RID (Runtime Identifier) used to identify target platforms where a .NET Core application runs.
If the RID doesn't match the platform target then the SDK produces the above kind of errors.
For example, win10-x64 RID with <PlatformTarget>x86</PlatformTarget> in the project file.
Troubleshooting steps:
<PlatformTarget>x86</PlatformTarget> enables the IIS app pool for 32-bit apps in an x86 framework-dependent deployment and set Enable 32-bit Apps to True from the app pool's Advanced Settings of IIS Manager.
500.30 is In-Process Startup Failure as it's cause can be usually determined from entries in the Application Event Log and the ASP .NET Core Module stdout log.
The app is misconfigured due to targeting a version of the ASP .NET Core shared framework that isn't present. Check which versions of the ASP .NET Core Shared framework are installed on the target machine.
If you're using Azure Key Vault, check the policies in the targeted Key Vault to ensure that the correct permissions are granted.
Also, please visit this Thread related to logging not working fix.
And Application Insights should be enabled to get the log files in the Storage account.
You can stream the logs from the portal or using CLI:
az webapp log tail --name appname --resource-group myResourceGroup
Use this reference to get the logs using the simple queries.

You need to enable application logging first.
Click on the App Service logs menu
In Application logging, select File System
In Quota (MB), specify the disk quota for the application logs. In Retention Period (Days), set the number of days the logs should be retained.
Save
You can stream the logs from the portal or by using the CLI
az webapp log tail --name appname --resource-group myResourceGroup

Related

Azure App Service with windows container http logs are missing the cs-username

I have an asp.net 5 web application on .NET Framework 4.8 running as an azure app service with a windows server 2019 container image. I setup a diagnostic setting to send the 'AppServiceHTTPLogs' to an event hub and when inspecting the logs, I noticed that the CsUsername property is missing for authenticated requests.
Running the same container image locally or even as an Azure Container Instance and inspecting the IIS logs on the container I can see the username so it's something to do with how and where the https logs are captured when running as an app service where the logs don't pick up on the authenticated principal's identity name.
Has anybody else run into this? Do I need to expose the principal as a response header for the logging to pick it up?
UPDATE: 02/24/2022
In addition to asking here I had also started a case with azure support inquiring about why the web server logs from an azure app service on a windows app service plan running a windows container is missing the cs-username information whereas consoling the running container of the app service and inspecting the w3c log in C:\inetpub\logs\LogFiles\W3SVC1 shows the cs-username value.
They finally got back and said:
At this moment I'm afraid that this feature is not supported for the architecture that you have set, the only way to get the details for the CsUsername is to deploy a Linux App Service and then target an Azure Storage account as the data endpoint.
That doesn't help me at all since I can't run a .NET Framework 4.8 ASP.NET MVC 5 application container in a Linux app service plan. Generally, through this ordeal of deploying windows containers to run as an azure app service with an Azure DevOps pipeline to running the container as an azure app service, I've found microsoft's support for running windows based containers to be very challenging and without much ongoing support. They try to push the linux hosting environment which unfortunately is an option only if your architecture is based on the .NET core framework.
Has anybody else run into this? Do I need to expose the principal as a
response header for the logging to pick it up?
This issue could be resolved in 2 different ways below are the resolution steps
A] Change applicationHost.config directly
Edit the applicationHost.config file for the Advanced Logging feature using the following steps:
Open the C:\Windows\System32\inetsrv\config\applicationHost.config file in a text editor.
Locate the advancedLogging section.
In advancedLogging, locate the <field id='UserName'...> entry.
<field id="UserName" sourceName="UserName" sourceType="
RequestHeader " logHeaderName="cs-username" category="Default" loggingDataType="TypeLPCSTR" />
Modify the sourceType field to be BuiltIn, as follows:
<field id="UserName" sourceName="UserName" sourceType="
BuiltIn " logHeaderName="cs-username" category="Default" loggingDataType="TypeLPCSTR" />
B] Change applicationHost.config by Appcmd.exe
You can use the appcmd.exe tool to make the configuration changes .
Run this command :
appcmd.exe set config -section:system.webServer/advancedLogging/server
/fields.[id='UserName'].sourceType:"BuiltIn" /commit:apphost
For complete information you can go through the below mentioned links
No cs-username data in Advanced Logging - Internet Information Services | Microsoft Docs
cs-username not populated in IIS logs · Issue #6741 · dotnet/aspnetcore · GitHub

Azure Web App with Linux Logging not works

i try my first steps with Azure. I have upload a WebApp (Blazor WASM Serverhosted) on a Linux System. Now i want to see the logs. My application brokes on Azure on startup. Everything I have tried has not worked.
The logstream shows nothing.
The Monitoring/logs are disabled
I activate in Monitoring/App Service Logs the File System and go to FTP Folder and i don't find a log-folder or something like this
I hope for help to fix my App or Configuration on Azure
Still the issue can be available in github . You can achieve this by using below steps.
Steps provided here. And I am deployed in Linux app service
Now you can be able to view the logs in application insights
You can add/modify the custom logs as well by using the custom telemetry client.
Refer here for detailed information

What's the correct way to have webapp logs in Azure?

We are developing an application based on Azure webapps and are having troubles understanding how to get basic logs from them. There seems to be at least 3 different ways to get some logs:
I can access Kudu (?) logs using URL https://my-webapp.scm.azurewebsites.net/
I should be able to access the same (?) logs using az webapp log but when I use show command it says no logs are activated
I can also access some logs using the Diagnose and Solve Problems menu in the Azure UI but that's cumbersome
What I would like is very simply to be able to do a tail on logs on a running webapp and get all logs that are generated by it, whether it be HTTP request logs from the hosting HTTP server, system logs or applicative level logs.
Can someone point me at the right documents explaining what's the correct way to do that?
To diagnose issues is to look at trace files. Kudu service as well as its application write traces to the /Logfiles folder. You may refer to below link on this:
https://github.com/projectkudu/kudu/wiki/Diagnostic-Log-Stream
https://github.com/projectkudu/kudu/wiki/Kudu-console
Also, you need turn on the diagnostics logs from the Azure Portal or from Azure PowerShell (using the Set-AzureWebsite cmdlet).
If using Azure CLI to filter specific log types, such as HTTP, use the --Path parameter.
az webapp log tail --name appname --resource-group myResourceGroup --path http
Reference: Enable diagnostics logging for apps in Azure App Service

How to view errors being generated by Azure Compute Emulator

I have a WCF service solution which contains the WCF service and a Azure Cloud Service project.
When running the cloud service project in the Azure Compute Emulator (version 2.5 on my PC), all I see in the output for each role is
[fabric] Role state Busy
[fabric] Role state Aborted
I've tweaked the logging level in Compute Emulator to log Warning, or Error and even tried Critical, but no more detailed messages are displayed. I have been Googling to see if there are any event log entries, or log files on disk, that I can view to find out why the cloud service is not working, but to no avail.
What can I do to find out more about what is causing the Cloud Service role to abort and and retry?
Diagnostics logs are not collected in the Azure compute emulator – For projects that target the Azure SDK version 2.5, the Azure compute emulator no longer supports the collection of diagnostics logs, including performance counters, infrastructure logs, IIS logs, and event logs. In addition, logs are no longer stored in Azure storage or development storage. You can continue to view application logs in the Visual Studio Output window or the compute emulator. This only affects projects that target Azure SDK version 2.5; projects that continue to target Azure SDK 2.4 are not affected.
Source: http://msdn.microsoft.com/en-us/library/azure/dn873976.aspx
In my case, it turned out to be a startup task defined in ServiceDefinition.csdef that was the problem. After I removed the <Task> my service ran fine in Compute Emulator.

Azure Worker Role / Web Role not reading from ServiceConfig

I have an Azure Worker Role (WR) which is supposed to pick up it's config from the .cscfg files using:
var setting = CloudConfigurationManager.GetSetting("My.Setting.Name");
Running in the emulator this is fine, I get the:
Getting "My.Setting.Name" from ServiceRuntime: PASS.
message. However, when I publish to my remote environment, I get:
Getting "My.Setting.Name" from ServiceRuntime: FAIL.
Getting "My.Setting.Name" from ConfigurationManager: FAIL.
messages. In the 'CloudServices/Configure' section of the Azure Management Portal I can see the setting listed in the configuration, and it's set correctly.
I'm using Azure SDK 2.0
Are you deploying correct Azure SDK .DLL's with your project? Did you by chance upgrade recently to a newer Azure SDK? I would check your .DLL references to make sure that they all match across the solution

Resources