Skip to content

Commit 80bff1f

Browse files
committed
SE 158364
1 parent b837cf2 commit 80bff1f

1 file changed

Lines changed: 26 additions & 6 deletions

File tree

learn-pr/wwl-azure/configure-web-app-settings/includes/5-enable-diagnostic-logging.md

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ The following table shows the types of logging, the platforms supported, and whe
1212

1313
## Enable application logging (Windows)
1414

15-
1. To enable application logging for Windows apps in the Azure portal, navigate to your app and select **App Service logs**.
15+
1. To enable application logging for Windows apps in the Azure portal, navigate to your app and select **Monitoring** > **App Service logs**.
1616

1717
1. Select **On** for either **Application Logging (Filesystem)** or **Application Logging (Blob)**, or both. The **Filesystem** option is for temporary debugging purposes, and turns itself off in 12 hours. The **Blob** option is for long-term logging, and needs a blob storage container to write logs to.
1818

@@ -57,25 +57,42 @@ In your application code, you use the usual logging facilities to send log messa
5757
System.Diagnostics.Trace.TraceError("If you're seeing this, something bad happened");
5858
```
5959

60-
By default, ASP.NET Core uses the `Microsoft.Extensions.Logging.AzureAppServices` logging provider.
60+
ASP.NET Core includes the Azure App Service logging provider. Enable it when configuring logging, for example:
6161

62-
* Python applications can use the [OpenCensus package](/azure/azure-monitor/app/opencensus-python) to send logs to the application diagnostics log.
62+
```csharp
63+
builder.Logging.AddAzureWebAppDiagnostics();
64+
```
65+
66+
* Python applications should use [OpenTelemetry with Azure Monitor](/azure/azure-monitor/app/opentelemetry-enable) to send logs to the application diagnostics log.
67+
68+
## Send logs to Azure Monitor
69+
70+
You can forward platform and application logs to Azure Monitor destinations via Diagnostic Settings.
71+
72+
* In the Azure portal, open your app and select **Monitoring** > **Diagnostic settings**, then add a diagnostic setting to send logs to a Log Analytics workspace, Storage account, or Event Hub.
73+
* Common categories include **AppServiceHTTPLogs** (web server logs) and **AppServiceConsoleLogs** (stdout/stderr). For details, see [Supported resource logs for Microsoft.Web](/azure/app-service/monitor-app-service-reference#supported-resource-logs-for-microsoftweb).
6374

6475
## Stream logs
6576

66-
Before you stream logs in real time, enable the log type that you want. Any information written to files ending in .txt, .log, or .htm that are stored in the `/LogFiles` directory (`d:/home/logfiles`) is streamed by App Service.
77+
Before you stream logs in real time, enable the log type that you want. Any information written to files ending in .txt, .log, or .htm that are stored in the `/home/LogFiles` directory (Windows: `D:\home\LogFiles`) is streamed by App Service.
6778

6879
> [!NOTE]
6980
> Some types of logging buffer write to the log file, which can result in out of order events in the stream. For example, an application log entry that occurs when a user visits a page may be displayed in the stream before the corresponding HTTP log entry for the page request.
7081

7182
* Azure portal - To stream logs in the Azure portal, navigate to your app and select **Log stream**.
7283

73-
* Azure CLI - To stream logs live in Cloud Shell, use the following command:
84+
* Azure CLI - To stream logs live in Cloud Shell, use the following command (note: Cloud Shell may not work for some Linux-based plans; use the local CLI if needed):
7485

7586
```bash
7687
az webapp log tail --name appname --resource-group myResourceGroup
7788
```
7889

90+
To filter specific log types, such as HTTP or application logs, use the `--provider` parameter, for example:
91+
92+
```bash
93+
az webapp log tail --name appname --resource-group myResourceGroup --provider http
94+
```
95+
7996
* Local console - To stream logs in the local console, install Azure CLI and sign in to your account. Once signed in, follow the instructions shown for Azure CLI.
8097

8198
## Access log files
@@ -85,7 +102,10 @@ If you configure the Azure Storage blobs option for a log type, you need a clien
85102
For logs stored in the App Service file system, the easiest way is to download the ZIP file in the browser at:
86103

87104
* Linux/container apps: `https://<app-name>.scm.azurewebsites.net/api/logs/docker/zip`
88-
* Windows apps: `https://<app-name>.scm.azurewebsites.net/api/dump`
105+
* Windows apps: `https://<app-name>.scm.azurewebsites.net/api/logs/zip`
106+
107+
> [!NOTE]
108+
> The `api/dump` endpoint downloads a full diagnostic dump, not just logs. Use `api/logs/zip` to download only log files.
89109

90110
For Linux/container apps, the ZIP file contains console output logs for both the docker host and the docker container. For a scaled-out app, the ZIP file contains one set of logs for each instance. In the App Service file system, these log files are the contents of the */home/LogFiles* directory.
91111

0 commit comments

Comments
 (0)