Skip to content

Commit a4adf21

Browse files
Merge pull request #33059 from anurse/patch-1
Update docs on azure-monitor for ILogger in response to ASP.NET Core 3.0 change
2 parents 4fd89f6 + 51a7188 commit a4adf21

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

articles/azure-monitor/app/ilogger.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,9 @@ public class ValuesController : ControllerBase
102102

103103
### Capture ILogger logs from Startup.cs and Program.cs in ASP.NET Core apps
104104

105+
> [!NOTE]
106+
> 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+
105108
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.
106109

107110
The following examples demonstrate this capability with **Program.cs** and **Startup.cs**.

0 commit comments

Comments
 (0)