You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/azure-monitor/app/asp-net-troubleshoot-no-data.md
+3-2Lines changed: 3 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,7 +10,8 @@ ms.date: 07/23/2018
10
10
11
11
---
12
12
13
-
# Troubleshooting no data - Application Insights for .NET
13
+
# Troubleshooting no data - Application Insights for .NET/.NET Core
14
+
14
15
## Some of my telemetry is missing
15
16
*In Application Insights, I only see a fraction of the events that are being generated by my app.*
16
17
@@ -209,7 +210,7 @@ Follow these instructions to capture troubleshooting logs for your framework.
209
210
210
211
1. Install the [Microsoft.AspNet.ApplicationInsights.HostingStartup](https://www.nuget.org/packages/Microsoft.AspNet.ApplicationInsights.HostingStartup) package from NuGet. The version you install must match the current installed version of `Microsoft.ApplicationInsights`
211
212
212
-
The latest version of Microsoft.ApplicationInsights.AspNetCore is 2.7.1, and it refers to Microsoft.ApplicationInsights version 2.10. Hence the version of Microsoft.AspNet.ApplicationInsights.HostingStartup to be installed should be 2.10.0
213
+
The latest version of Microsoft.ApplicationInsights.AspNetCore is 2.8.2, and it refers to Microsoft.ApplicationInsights version 2.11.2. Hence the version of Microsoft.AspNet.ApplicationInsights.HostingStartup to be installed should be 2.11.2
213
214
214
215
2. Modify `ConfigureServices` method in your `Startup.cs` class.:
Copy file name to clipboardExpand all lines: articles/azure-monitor/app/console.md
+6-1Lines changed: 6 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -23,7 +23,7 @@ You need a subscription with [Microsoft Azure](https://azure.com). Sign in with
23
23
## Getting started
24
24
25
25
* In the [Azure portal](https://portal.azure.com), [create an Application Insights resource](../../azure-monitor/app/create-new-resource.md). For application type, choose **General**.
26
-
* Take a copy of the Instrumentation Key. Find the key in the **Essentials** drop-down of the new resource you created.
26
+
* Take a copy of the Instrumentation Key. Find the key in the **Essentials** drop-down of the new resource you created.
* Set the instrumentation key in your code before tracking any telemetry (or set APPINSIGHTS_INSTRUMENTATIONKEY environment variable). After that, you should be able to manually track telemetry and see it on the Azure portal
29
29
@@ -35,6 +35,10 @@ var telemetryClient = new TelemetryClient(configuration);
35
35
telemetryClient.TrackTrace("Hello World!");
36
36
```
37
37
38
+
> [!NOTE]
39
+
> Telemetry is not sent instantly. Telemetry items are batched and sent by the ApplicationInsights SDK. In Console apps, which exits right after calling `Track()` methods, telemetry may not be sent unless `Flush()` and `Sleep` is done before the app exits as shown in [full example](#full-example) later in this article.
40
+
41
+
38
42
* Install latest version of [Microsoft.ApplicationInsights.DependencyCollector](https://www.nuget.org/packages/Microsoft.ApplicationInsights.DependencyCollector) package - it automatically tracks HTTP, SQL, or some other external dependency calls.
39
43
40
44
You may initialize and configure Application Insights from the code or using `ApplicationInsights.config` file. Make sure initialization happens as early as possible.
@@ -43,6 +47,7 @@ You may initialize and configure Application Insights from the code or using `Ap
43
47
> Instructions referring to **ApplicationInsights.config** are only applicable to apps that are targeting the .NET Framework, and do not apply to .NET Core applications.
44
48
45
49
### Using config file
50
+
46
51
By default, Application Insights SDK looks for `ApplicationInsights.config` file in the working directory when `TelemetryConfiguration` is being created
Copy file name to clipboardExpand all lines: articles/azure-monitor/app/ilogger.md
+13-13Lines changed: 13 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,8 +4,8 @@ description: Samples of using the Azure Application Insights ILogger provider wi
4
4
ms.service: azure-monitor
5
5
ms.subservice: application-insights
6
6
ms.topic: conceptual
7
-
author: cijothomas
8
-
ms.author: cithomas
7
+
author: mrbullwinkle
8
+
ms.author: mbullwin
9
9
ms.date: 02/19/2019
10
10
11
11
ms.reviewer: mbullwin
@@ -18,11 +18,12 @@ To learn more, see [Logging in ASP.NET Core](https://docs.microsoft.com/aspnet/c
18
18
19
19
## ASP.NET Core applications
20
20
21
-
ApplicationInsightsLoggerProvider is enabled by default in [Microsoft.ApplicationInsights.AspNet SDK](https://www.nuget.org/packages/Microsoft.ApplicationInsights.AspNetCore) version 2.7.0-beta3 (and later) when you turn on regular Application Insights monitoring through either of the standard methods:
22
-
- By calling the **UseApplicationInsights** extension method on IWebHostBuilder
21
+
ApplicationInsightsLoggerProvider is enabled by default in [Microsoft.ApplicationInsights.AspNet SDK](https://www.nuget.org/packages/Microsoft.ApplicationInsights.AspNetCore) version 2.7.1 (and later) when you turn on regular Application Insights monitoring through either of the standard methods:
22
+
23
+
- By calling the **UseApplicationInsights** extension method on IWebHostBuilder
23
24
- By calling the **AddApplicationInsightsTelemetry** extension method on IServiceCollection
24
25
25
-
ILogger logs that ApplicationInsightsLoggerProvider captures are subject to the same configuration as any other telemetry that's collected. They have the same set of TelemetryInitializers and TelemetryProcessors, use the same TelemetryChannel, and are correlated and sampled in the same way as other telemetry. If you use version 2.7.0-beta3 or later, no action is required to capture ILogger logs.
26
+
ILogger logs that ApplicationInsightsLoggerProvider captures are subject to the same configuration as any other telemetry that's collected. They have the same set of TelemetryInitializers and TelemetryProcessors, use the same TelemetryChannel, and are correlated and sampled in the same way as other telemetry. If you use version 2.7.1 or later, no action is required to capture ILogger logs.
26
27
27
28
Only *Warning* or higher ILogger logs (from all categories) are sent to Application Insights by default. But you can [apply filters to modify this behavior](#control-logging-level). Additional steps are required to capture ILogger logs from **Program.cs** or **Startup.cs**. (See [Capturing ILogger logs from Startup.cs and Program.cs in ASP.NET Core applications](#capture-ilogger-logs-from-startupcs-and-programcs-in-aspnet-core-apps).)
28
29
@@ -105,7 +106,7 @@ public class ValuesController : ControllerBase
105
106
> [!NOTE]
106
107
> In ASP.NET Core 3.0 and later, it is no longer possible to inject `ILogger` in Startup.cs and Program.cs. See https://github.com/aspnet/Announcements/issues/353 for more details.
107
108
108
-
The new ApplicationInsightsLoggerProvider can capture logs from early in the application-startup pipeline. Although ApplicationInsightsLoggerProvider is automatically enabled in Application Insights (starting with version 2.7.0-beta3), it doesn't have an instrumentation key set up until later in the pipeline. So, only logs from **Controller**/other classes will be captured. To capture every log starting with **Program.cs** and **Startup.cs** itself, you must explicitly enable an instrumentation key for ApplicationInsightsLoggerProvider. Also, *TelemetryConfiguration* is not fully set up when you log from **Program.cs** or **Startup.cs** itself. So those logs will have a minimum configuration that uses InMemoryChannel, no sampling, and no standard telemetry initializers or processors.
109
+
The new ApplicationInsightsLoggerProvider can capture logs from early in the application-startup pipeline. Although ApplicationInsightsLoggerProvider is automatically enabled in Application Insights (starting with version 2.7.1), it doesn't have an instrumentation key set up until later in the pipeline. So, only logs from **Controller**/other classes will be captured. To capture every log starting with **Program.cs** and **Startup.cs** itself, you must explicitly enable an instrumentation key for ApplicationInsightsLoggerProvider. Also, *TelemetryConfiguration* is not fully set up when you log from **Program.cs** or **Startup.cs** itself. So those logs will have a minimum configuration that uses InMemoryChannel, no sampling, and no standard telemetry initializers or processors.
109
110
110
111
The following examples demonstrate this capability with **Program.cs** and **Startup.cs**.
111
112
@@ -199,7 +200,7 @@ public class Startup
199
200
200
201
## Migrate from the old ApplicationInsightsLoggerProvider
201
202
202
-
Microsoft.ApplicationInsights.AspNet SDK versions before 2.7.0-beta2 supported a logging provider that's now obsolete. This provider was enabled through the **AddApplicationInsights()** extension method of ILoggerFactory. We recommend that you migrate to the new provider, which involves two steps:
203
+
Microsoft.ApplicationInsights.AspNet SDK versions before 2.7.1 supported a logging provider that's now obsolete. This provider was enabled through the **AddApplicationInsights()** extension method of ILoggerFactory. We recommend that you migrate to the new provider, which involves two steps:
203
204
204
205
1. Remove the *ILoggerFactory.AddApplicationInsights()* call from the **Startup.Configure()** method to avoid double logging.
205
206
2. Reapply any filtering rules in code, because they will not be respected by the new provider. Overloads of *ILoggerFactory.AddApplicationInsights()* took minimum LogLevel or filter functions. With the new provider, filtering is part of the logging framework itself. It's not done by the Application Insights provider. So any filters that are provided via *ILoggerFactory.AddApplicationInsights()* overloads should be removed. And filtering rules should be provided by following the [Control logging level](#control-logging-level) instructions. If you use *appsettings.json* to filter logging, it will continue to work with the new provider, because both use the same provider alias, *ApplicationInsights*.
@@ -217,8 +218,7 @@ You can still use the old provider. (It will be removed only in a major version
217
218
## Console application
218
219
219
220
> [!NOTE]
220
-
> There is a new beta Application Insights SDK called [Microsoft.ApplicationInsights.WorkerService](https://www.nuget.org/packages/Microsoft.ApplicationInsights.WorkerService) which can used to enable Application Insights (ILogger and other Application Insights telemetry) for any Console Applications. It is recommended to use this package and associated instructions from [here](../../azure-monitor/app/worker-service.md).
221
-
The following example will be deprecated once stable version of this new package is released.
221
+
> There is a new Application Insights SDK called [Microsoft.ApplicationInsights.WorkerService](https://www.nuget.org/packages/Microsoft.ApplicationInsights.WorkerService) which can used to enable Application Insights (ILogger and other Application Insights telemetry) for any Console Applications. It is recommended to use this package and associated instructions from [here](../../azure-monitor/app/worker-service.md).
222
222
223
223
The following code shows a sample console application that's configured to send ILogger traces to Application Insights.
224
224
@@ -363,11 +363,11 @@ The following code snippet configures logs for *Warning* and above from all cate
363
363
364
364
### What are the old and new versions of ApplicationInsightsLoggerProvider?
365
365
366
-
[Microsoft.ApplicationInsights.AspNetSDK](https://www.nuget.org/packages/Microsoft.ApplicationInsights.AspNetCore) included a built-in ApplicationInsightsLoggerProvider (Microsoft.ApplicationInsights.AspNetCore.Logging.ApplicationInsightsLoggerProvider), which was enabled through **ILoggerFactory** extension methods. This provider is marked obsolete from version 2.7.0-beta2. It will be removed completely in the next major version change. The [Microsoft.ApplicationInsights.AspNetCore 2.6.1](https://www.nuget.org/packages/Microsoft.ApplicationInsights.AspNetCore) package itself isn't obsolete. It's required to enable monitoring of requests, dependencies, and so on.
366
+
[Microsoft.ApplicationInsights.AspNetSDK](https://www.nuget.org/packages/Microsoft.ApplicationInsights.AspNetCore) included a built-in ApplicationInsightsLoggerProvider (Microsoft.ApplicationInsights.AspNetCore.Logging.ApplicationInsightsLoggerProvider), which was enabled through **ILoggerFactory** extension methods. This provider is marked obsolete from version 2.7.1. It will be removed completely in the next major version change. The [Microsoft.ApplicationInsights.AspNetCore 2.6.1](https://www.nuget.org/packages/Microsoft.ApplicationInsights.AspNetCore) package itself isn't obsolete. It's required to enable monitoring of requests, dependencies, and so on.
367
367
368
368
Thesuggestedalternativeisthenewstandalonepackage [Microsoft.Extensions.Logging.ApplicationInsights](https://www.nuget.org/packages/Microsoft.Extensions.Logging.ApplicationInsights), which contains an improved ApplicationInsightsLoggerProvider (Microsoft.Extensions.Logging.ApplicationInsights.ApplicationInsightsLoggerProvider) and extension methods on ILoggerBuilder for enabling it.
369
369
370
-
[Microsoft.ApplicationInsights.AspNetSDK](https://www.nuget.org/packages/Microsoft.ApplicationInsights.AspNetCore) version 2.7.0-beta3 takes a dependency on the new package and enables ILogger capture automatically.
370
+
[Microsoft.ApplicationInsights.AspNetSDK](https://www.nuget.org/packages/Microsoft.ApplicationInsights.AspNetCore) version 2.7.1 takes a dependency on the new package and enables ILogger capture automatically.
371
371
372
372
### Why are some ILogger logs shown twice in Application Insights?
373
373
@@ -394,7 +394,7 @@ If you experience double logging when you debug from Visual Studio, set `EnableD
394
394
}
395
395
```
396
396
397
-
### I updated to [Microsoft.ApplicationInsights.AspNet SDK](https://www.nuget.org/packages/Microsoft.ApplicationInsights.AspNetCore) version 2.7.0-beta3, and logs from ILogger are captured automatically. How do I turn off this feature completely?
397
+
### I updated to [Microsoft.ApplicationInsights.AspNet SDK](https://www.nuget.org/packages/Microsoft.ApplicationInsights.AspNetCore) version 2.7.1, and logs from ILogger are captured automatically. How do I turn off this feature completely?
398
398
399
399
Seethe [Controllogginglevel](../../azure-monitor/app/ilogger.md#control-logging-level) sectiontoseehowtofilterlogsingeneral. Toturn-offApplicationInsightsLoggerProvider, use `LogLevel.None`:
400
400
@@ -452,7 +452,7 @@ If you prefer to always send TraceTelemetry, use this snippet: ```builder.AddApp
452
452
453
453
### I don't have the SDK installed, and I use the Azure Web Apps extension to enable Application Insights for my ASP.NET Core applications. How do I use the new provider?
### I'm using the standalone package Microsoft.Extensions.Logging.ApplicationInsights and enabling Application Insights provider by calling **builder.AddApplicationInsights("ikey")**. Is there an option to get an instrumentation key from configuration?
> An instrumentation key specified in code wins over the environment variable `APPINSIGHTS_INSTRUMENTATIONKEY`, which wins over other options.
134
134
135
135
## ASP.NET Core background tasks with hosted services
136
+
136
137
[This](https://docs.microsoft.com/aspnet/core/fundamentals/host/hosted-services?view=aspnetcore-2.2&tabs=visual-studio) document describes how to create backgrounds tasks in ASP.NET Core 2.1/2.2 application.
137
138
138
139
Full example is shared [here](https://github.com/microsoft/ApplicationInsights-Home/tree/master/Samples/WorkerServiceSDK/BackgroundTasksWithHostedService)
0 commit comments