Skip to content

Commit aef1885

Browse files
Merge pull request #266532 from cijothomas/cijothomas/aspnet-body
AppInsights request body logging
2 parents 4424dec + e0e15fa commit aef1885

File tree

1 file changed

+12
-47
lines changed

1 file changed

+12
-47
lines changed

articles/azure-monitor/app/asp-net-core.md

Lines changed: 12 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -656,6 +656,16 @@ public class HomeController : Controller
656656

657657
For more information about custom data reporting in Application Insights, see [Application Insights custom metrics API reference](./api-custom-events-metrics.md). A similar approach can be used for sending custom metrics to Application Insights by using the [GetMetric API](./get-metric.md).
658658

659+
### How do I capture Request and Response body in my telemetry?
660+
661+
ASP.NET Core has [built-in
662+
support](https://learn.microsoft.com/aspnet/core/fundamentals/http-logging) for
663+
logging HTTP Request/Response information (including body) via
664+
[`ILogger`](#ilogger-logs). It is recommended to leverage this. This may
665+
potentially expose personally identifiable information (PII) in telemetry, and
666+
can cause costs (performance costs and Application Insights billing) to
667+
significantly increase, so evaluate the risks carefully before using this.
668+
659669
### How do I customize ILogger logs collection?
660670

661671
The default setting for Application Insights is to only capture **Warning** and more severe logs.
@@ -721,55 +731,10 @@ If the SDK is installed at build time as shown in this article, you don't need t
721731
Yes. Feature support for the SDK is the same in all platforms, with the following exceptions:
722732

723733
* The SDK collects [event counters](./eventcounters.md) on Linux because [performance counters](./performance-counters.md) are only supported in Windows. Most metrics are the same.
724-
* Although `ServerTelemetryChannel` is enabled by default, if the application is running in Linux or macOS, the channel doesn't automatically create a local storage folder to keep telemetry temporarily if there are network issues. Because of this limitation, telemetry is lost when there are temporary network or server issues. To work around this issue, configure a local folder for the channel.
725-
726-
### [ASP.NET Core 6.0](#tab/netcore6)
727-
728-
```csharp
729-
using Microsoft.ApplicationInsights.Channel;
730-
using Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel;
731-
732-
var builder = WebApplication.CreateBuilder(args);
733-
734-
// The following will configure the channel to use the given folder to temporarily
735-
// store telemetry items during network or Application Insights server issues.
736-
// User should ensure that the given folder already exists
737-
// and that the application has read/write permissions.
738-
builder.Services.AddSingleton(typeof(ITelemetryChannel),
739-
new ServerTelemetryChannel () {StorageFolder = "/tmp/myfolder"});
740-
builder.Services.AddApplicationInsightsTelemetry();
741-
742-
var app = builder.Build();
743-
```
744-
745-
### [ASP.NET Core 3.1](#tab/netcore3)
746-
747-
```csharp
748-
using Microsoft.ApplicationInsights.Channel;
749-
using Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel;
750-
751-
public void ConfigureServices(IServiceCollection services)
752-
{
753-
// The following will configure the channel to use the given folder to temporarily
754-
// store telemetry items during network or Application Insights server issues.
755-
// User should ensure that the given folder already exists
756-
// and that the application has read/write permissions.
757-
services.AddSingleton(typeof(ITelemetryChannel),
758-
new ServerTelemetryChannel () {StorageFolder = "/tmp/myfolder"});
759-
services.AddApplicationInsightsTelemetry();
760-
}
761-
```
762-
763-
> [!NOTE]
764-
> This .NET version is no longer supported.
765-
766-
---
767-
768-
This limitation isn't applicable from version [2.15.0](https://www.nuget.org/packages/Microsoft.ApplicationInsights.AspNetCore/2.15.0) and later.
769734

770-
### Is this SDK supported for the new .NET Core 3.X Worker Service template applications?
735+
### Is this SDK supported for Worker Services?
771736

772-
This SDK requires `HttpContext`. It doesn't work in any non-HTTP applications, including the .NET Core 3.X Worker Service applications. To enable Application Insights in such applications by using the newly released Microsoft.ApplicationInsights.WorkerService SDK, see [Application Insights for Worker Service applications (non-HTTP applications)](worker-service.md).
737+
No. Please use [Application Insights for Worker Service applications (non-HTTP applications)](worker-service.md) for worker services.
773738

774739
### How can I uninstall the SDK?
775740

0 commit comments

Comments
 (0)