Skip to content

Commit 8c05dae

Browse files
authored
Merge pull request #296555 from TimShererWithAquent/us406760-07
AI Freshness Edit: App Service (2 of 4)
2 parents 9d4d819 + 95b187b commit 8c05dae

File tree

2 files changed

+32
-34
lines changed

2 files changed

+32
-34
lines changed
-144 KB
Loading

articles/app-service/troubleshoot-diagnostic-logs.md

Lines changed: 32 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,23 @@ title: Enable Diagnostic Logging
33
description: Learn how to enable diagnostic logging and add instrumentation to your application, along with how to access the information logged by Azure.
44
ms.assetid: c9da27b2-47d4-4c33-a3cb-1819955ee43b
55
ms.topic: how-to
6-
ms.date: 08/21/2024
6+
ms.date: 03/27/2025
77
ms.author: msangapu
88
author: msangapu-msft
99
ms.custom: devx-track-csharp, ai-video-demo, linux-related-content
1010
ai-usage: ai-assisted
11+
#customer intent: As an app developer, I want to understand troubleshooting in Azure App Service to fix issues with my app and make improvements.
1112
---
1213

1314
# Enable diagnostic logging for apps in Azure App Service
1415

15-
[!INCLUDE [regionalization-note](./includes/regionalization-note.md)]
16-
1716
Azure provides built-in diagnostics to assist with debugging an [Azure App Service app](overview.md). In this article, you learn how to enable diagnostic logging and add instrumentation to your application. You also learn how to access the information that Azure logs.
1817

19-
The following video complements the steps in this article by illustrating how to enable diagnostic logging for apps.
20-
21-
> [!VIDEO 62f2edbe-1063-4ec3-a76f-faa0bd783f2f]
18+
[!INCLUDE [regionalization-note](./includes/regionalization-note.md)]
2219

23-
This article uses the [Azure portal](https://portal.azure.com) and the Azure CLI to work with diagnostic logs. For information on working with diagnostic logs by using Visual Studio, see [Troubleshoot an app in Azure App Service by using Visual Studio](troubleshoot-dotnet-visual-studio.md).
20+
This article uses the [Azure portal](https://portal.azure.com) and the Azure CLI to work with diagnostic logs. For information on working with diagnostic logs by using Visual Studio, see [Troubleshoot an app in Azure App Service using Visual Studio](troubleshoot-dotnet-visual-studio.md).
2421

25-
In addition to the logging instructions in this article, you can use the Azure Monitor integrated logging capability. The [Send logs to Azure Monitor](#send-logs-to-azure-monitor) section in this article provides more information about this capability.
22+
In addition to the logging instructions in this article, you can use the Azure Monitor integrated logging capability. For more information, see [Send logs to Azure Monitor](#send-logs-to-azure-monitor).
2623

2724
> [!NOTE]
2825
> App Service provides a dedicated, interactive diagnostic tool to help you troubleshoot your application. For more information, see [Azure App Service diagnostics overview](overview-diagnostics.md).
@@ -31,11 +28,11 @@ In addition to the logging instructions in this article, you can use the Azure M
3128
3229
## Overview of logging types
3330

34-
|Type|Platform|Log storage location|Description|
35-
|-|-|-|-|
36-
| Application logging | Windows, Linux | App Service file system and/or Azure Storage blobs | Log messages that your application code generates. The messages can be generated by the web framework that you choose, or from your application code directly via the standard logging pattern of your language. Each message is assigned one of the following categories: **Critical**, **Error**, **Warning**, **Info**, **Debug**, or **Trace**. You can select how verbose you want the logging to be by setting the severity level when you enable application logging.|
37-
| Web server logging| Windows | App Service file system or Azure Storage blobs| Raw HTTP request data in the [W3C extended log file format](/windows/desktop/Http/w3c-logging). Each log message includes data such as the HTTP method, resource URI, client IP, client port, user agent, and response code. |
38-
| Detailed error messages| Windows | App Service file system | Copies of the .htm error pages that would have been sent to the client browser. For security reasons, detailed error pages shouldn't be sent to clients in production. But App Service can save the error page each time an application error that has HTTP code 400 or higher occurs. The page might contain information that can help determine why the server returns the error code. |
31+
| Type | Platform | Log storage location | Description |
32+
|:-----|:---------|:---------------------|:------------|
33+
| Application logging | Windows, Linux | App Service file system and/or Azure Storage blobs | Log messages that your application code generates. The messages can be generated by the web framework that you choose, or from your application code directly by using the standard logging pattern of your language. Each message is assigned one of the following categories: **Critical**, **Error**, **Warning**, **Info**, **Debug**, or **Trace**. You can select how verbose you want the logging to be by setting the severity level when you enable application logging.|
34+
| Web server logging | Windows | App Service file system or Azure Storage blobs | Raw HTTP request data in the [W3C extended log file format](/windows/desktop/Http/w3c-logging). Each log message includes data such as the HTTP method, resource URI, client IP, client port, user agent, and response code. |
35+
| Detailed error messages | Windows | App Service file system | Copies of the .htm error pages that would have been sent to the client browser. For security reasons, detailed error pages shouldn't be sent to clients in production. But App Service can save the error page each time an application error that has HTTP code 400 or higher occurs. The page might contain information that can help determine why the server returns the error code. |
3936
| Failed request tracing | Windows | App Service file system | Detailed tracing information on failed requests, including a trace of the IIS components used to process the request and the time taken in each component. This information is useful if you want to improve site performance or isolate a specific HTTP error. One folder is generated for each failed request. The folder contains the XML log file and the XSL stylesheet for viewing the log file. |
4037
| Deployment logging | Windows, Linux | App Service file system | Logs for when you publish content to an app. Deployment logging happens automatically, and there are no configurable settings for deployment logging. It helps you determine why a deployment failed. For example, if you use a [custom deployment script](https://github.com/projectkudu/kudu/wiki/Custom-Deployment-Script), you might use deployment logging to determine why the script is failing. |
4138

@@ -45,19 +42,19 @@ When logs are stored in the App Service file system, they're subject to the avai
4542

4643
To enable application logging for Windows apps in the [Azure portal](https://portal.azure.com):
4744

48-
1. Go to your app and select **App Service logs**.
45+
1. Go to your app and select **Monitoring** > **App Service logs**.
4946

5047
1. Select **On** for either or both of these options:
5148

52-
- **Filesystem**: This option is for temporary debugging purposes. It turns itself off in 12 hours.
53-
- **Blob**: This option is for long-term logging. It needs a blob storage container to write logs to.
49+
- **Application logging (Filesystem)**: This option is for temporary debugging purposes. It turns itself off in 12 hours.
50+
- **Application logging (Blob)**: This option is for long-term logging. It needs a blob storage container to write logs to.
5451

5552
The **Blob** option includes additional information in the log messages, such as the ID of the origin virtual machine instance of the log message (`InstanceId`), the thread ID (`Tid`), and a more granular time stamp ([`EventTickCount`](/dotnet/api/system.datetime.ticks)).
5653

5754
1. For **Level**, select the level of details to log. The following table shows the log categories included in each level:
5855

5956
| Level | Included categories |
60-
|-|-|
57+
|:-|:-|
6158
|**Disabled** | None |
6259
|**Error** | **Error**, **Critical** |
6360
|**Warning** | **Warning**, **Error**, **Critical**|
@@ -68,7 +65,7 @@ To enable application logging for Windows apps in the [Azure portal](https://por
6865

6966
If you write logs to blobs, the retention policy no longer applies if you delete the app but keep the logs in the blobs. For more information, see [Costs that might accrue after resource deletion](overview-manage-costs.md#costs-that-might-accrue-after-resource-deletion).
7067

71-
Currently, only .NET application logs can be written to blob storage. Java, PHP, Node.js, and Python application logs can be stored only in the App Service file system (without code modifications to write logs to external storage).
68+
Currently, only .NET application logs can be written to blob storage. Java, PHP, Node.js, and Python application logs can be stored only in the App Service file system without code modifications to write logs to external storage.
7269

7370
If you [regenerate your storage account's access keys](../storage/common/storage-account-create.md), you must reset the respective logging configuration to use the updated access keys:
7471

@@ -80,7 +77,7 @@ If you [regenerate your storage account's access keys](../storage/common/storage
8077

8178
To enable application logging for Linux apps or custom containers in the [Azure portal](https://portal.azure.com):
8279

83-
1. Go to your app and select **App Service logs**.
80+
1. Go to your app and select **Monitoring** > **App Service logs**.
8481

8582
1. In **Application logging**, select **File System**.
8683

@@ -94,7 +91,7 @@ To enable application logging for Linux apps or custom containers in the [Azure
9491

9592
To enable web server logging for Windows apps in the [Azure portal](https://portal.azure.com):
9693

97-
1. Go to your app and select **App Service logs**.
94+
1. Go to your app and select **Monitoring** > **App Service logs**.
9895

9996
1. For **Web server logging**, select **Storage** to store logs in blob storage, or select **File System** to store logs in the App Service file system.
10097

@@ -114,28 +111,29 @@ If you [regenerate your storage account's access keys](../storage/common/storage
114111

115112
To save the error page or failed request traces for Windows apps in the [Azure portal](https://portal.azure.com):
116113

117-
1. Go to your app and select **App Service logs**.
114+
1. Go to your app and select **Monitoring** > **App Service logs**.
118115

119-
1. Under **Detailed Error Logging** or **Failed Request Tracing**, select **On**.
116+
1. Under **Detailed error messages** or **Failed request tracing**, select **On**.
120117

121118
1. Select **Save**.
122119

123-
Both types of logs are stored in the App Service file system. Up to 50 errors (files or folders) are retained. When the number of HTML files exceeds 50, the oldest error files are automatically deleted.
120+
Both types of logs are stored in the App Service file system. It retains up to 50 errors (files or folders). When the number of HTML files exceeds 50, App Service deletes the oldest error files.
124121

125-
By default, failed request tracing captures a log of requests that failed with HTTP status codes between 400 and 600. To specify custom rules, you can override the `<traceFailedRequests>` section in the `Web.config` file.
122+
By default, failed request tracing captures a log of requests that failed with HTTP status codes between 400 and 600. To specify custom rules, override the `<traceFailedRequests>` section in the `Web.config` file.
126123

127124
## Add log messages in code
128125

129-
In your application code, you use the usual logging facilities to send log messages to the application logs. For example:
126+
In your application code, you can use the usual logging facilities to send log messages to the application logs. For example:
130127

131128
- ASP.NET applications can use the [System.Diagnostics.Trace](/dotnet/api/system.diagnostics.trace) class to log information to the application diagnostic log. For example:
132129

133-
```csharp
134-
System.Diagnostics.Trace.TraceError("If you're seeing this, something bad happened");
135-
```
130+
```csharp
131+
System.Diagnostics.Trace.TraceError("If you're seeing this, something bad happened");
132+
```
133+
134+
By default, ASP.NET Core uses the [Microsoft.Extensions.Logging.AzureAppServices](https://www.nuget.org/packages/Microsoft.Extensions.Logging.AzureAppServices) logging provider. For more information, see [ASP.NET Core logging in Azure](/aspnet/core/fundamentals/logging/). For information about WebJobs SDK logging, see [Get started with the Azure WebJobs SDK](./webjobs-sdk-get-started.md#enable-console-logging).
136135

137-
By default, ASP.NET Core uses the [Microsoft.Extensions.Logging.AzureAppServices](https://www.nuget.org/packages/Microsoft.Extensions.Logging.AzureAppServices) logging provider. For more information, see [ASP.NET Core logging in Azure](/aspnet/core/fundamentals/logging/). For information about WebJobs SDK logging, see [Get started with the Azure WebJobs SDK](./webjobs-sdk-get-started.md#enable-console-logging).
138-
- Python applications can use the [OpenCensus package](/previous-versions/azure/azure-monitor/app/opencensus-python) to send logs to the application diagnostic log.
136+
- Python applications can use OpenTelemetry to send logs to the application diagnostic log. For more information, see [Enable Azure Monitor OpenTelemetry](/azure/azure-monitor/app/opentelemetry-enable).
139137

140138
## Stream logs
141139

@@ -146,7 +144,7 @@ Before you stream logs in real time, enable the log type that you want. App Serv
146144
147145
### Azure portal
148146

149-
To stream logs in the [Azure portal](https://portal.azure.com), go to your app and select **Log stream**.
147+
To stream logs in the [Azure portal](https://portal.azure.com), go to your app and select **Monitoring** > **Log stream**.
150148

151149
### <a name = "in-cloud-shell"></a> Cloud Shell
152150

@@ -183,18 +181,18 @@ For Linux or custom containers, the ZIP file contains console output logs for bo
183181
For Windows apps, the ZIP file contains the contents of the `D:\Home\LogFiles` directory in the App Service file system. It has the following structure:
184182

185183
| Log type | Directory | Description |
186-
|-|-|-|
184+
|:-|:-|:-|
187185
| Application log |`/LogFiles/Application/` | Contains one or more text files. The format of the log messages depends on the logging provider that you use. |
188186
| Failed request trace | `/LogFiles/W3SVC#########/` | Contains XML files and an XSL file. You can view the formatted XML files in the browser. |
189187
| Detailed error log | `/LogFiles/DetailedErrors/` | Contains HTM error files. You can view the HTM files in the browser.<br/><br/>Another way to view the failed request traces is to go to your app page in the portal. On the left menu, select **Diagnose and solve problems**. Search for **Failed Request Tracing Logs**, and then select the icon to browse and view the trace that you want. |
190-
| Web server log | `/LogFiles/http/RawLogs/` | Contains text files formatted via the [W3C extended log file format](/windows/desktop/Http/w3c-logging). You can read these files by using a text editor or a tool like [Log Parser](https://www.iis.net/downloads/community/2010/04/log-parser-22).<br/><br/>App Service doesn't support the `s-computername`, `s-ip`, and `cs-version` fields. |
188+
| Web server log | `/LogFiles/http/RawLogs/` | Contains text files formatted by using the [W3C extended log file format](/windows/desktop/Http/w3c-logging). You can read these files by using a text editor or a tool like [Log Parser](https://www.iis.net/downloads/community/2010/04/log-parser-22).<br/><br/>App Service doesn't support the `s-computername`, `s-ip`, and `cs-version` fields. |
191189
| Deployment log | `/LogFiles/Git/` and `/deployments/` | Contains logs generated by the internal deployment processes, along with logs for Git deployments. |
192190

193191
## Send logs to Azure Monitor
194192

195193
With [Azure Monitor integration](https://aka.ms/appsvcblog-azmon), you can [create diagnostic settings](https://azure.github.io/AppService/2019/11/01/App-Service-Integration-with-Azure-Monitor.html#create-a-diagnostic-setting) to send logs to storage accounts, event hubs, and Log Analytics workspaces. When you add a diagnostic setting, App Service adds app settings to your app, which triggers an app restart.
196194

197-
:::image type="content" source="media/troubleshoot-diagnostic-logs/diagnostic-settings-page.png" alt-text="Screenshot that shows selections for displaying diagnostic settings and adding a diagnostic setting.":::
195+
:::image type="content" source="media/troubleshoot-diagnostic-logs/diagnostic-settings-page.png" alt-text="Screenshot that shows selections for displaying diagnostic settings and adding a diagnostic setting." lightbox="media/troubleshoot-diagnostic-logs/diagnostic-settings-page.png":::
198196

199197
### Supported log types
200198

0 commit comments

Comments
 (0)