Use host-managed logger for startup profiler logging#1123
Open
BenjaminMichaelis wants to merge 1 commit into
Open
Use host-managed logger for startup profiler logging#1123BenjaminMichaelis wants to merge 1 commit into
BenjaminMichaelis wants to merge 1 commit into
Conversation
Move the unsupported-profiler startup log to run after app build via DI ILogger<Program>, and remove the ad-hoc LoggerFactory creation/disposal so startup logging stays on the host-managed pipeline.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR aligns early startup logging with the host-managed ASP.NET Core logging pipeline by removing a manually created LoggerFactory and emitting the “skipping unsupported Azure Monitor profiler” log after the app is built.
Changes:
- Removed the ad-hoc
LoggerFactory.Create(...)+ explicitDispose()usage inProgram.cs. - Moved the
LogSkippingUnsupportedAzureMonitorProfilercall to afterbuilder.Build(). - Resolved
ILogger<Program>fromapp.Servicesso the message goes through configured host providers/filters.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Startup used a manually created
LoggerFactoryto emit an early log entry. That creates a separate logging pipeline from the host and is less consistent with ASP.NET Core startup logging patterns.What changed
LoggerFactory.Create(...)and its explicit disposal fromProgram.cs.LogSkippingUnsupportedAzureMonitorProfiler) but moved its call to afterbuilder.Build().app.Services.GetRequiredService<ILogger<Program>>()so startup logging stays on the host-managed providers and configuration.Notes for reviewers
This intentionally shifts that single pre-build log call to post-build, trading a tiny timing change for a single, consistent logging pipeline.
Validation
dotnet build .\EssentialCSharp.Web.slnx -c Release --no-restoredotnet test .\EssentialCSharp.Chat.Tests\EssentialCSharp.Chat.Tests.csproj -c Release --no-build --no-restore -- --no-ansi --no-progressEssentialCSharp.Web.Testsdid not exit cleanly in this environment (test session cancellation/timeout behavior).