Skip to content

Commit 63d7e7f

Browse files
authored
Merge pull request #79276 from MicrosoftDocs/repo_sync_working_branch
Confirm merge from repo_sync_working_branch to master to sync with https://github.com/Microsoft/azure-docs (branch master)
2 parents b2d53cd + a4adf21 commit 63d7e7f

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)