ASP.NET Core Minimal Hosting: Pre-Build Failures in File Logs
0 reputation · 13 Jan 2021, 06:25 UTC
For an ASP.NET Core minimal-hosting application targeting .NET 8 or later, the logging contract needs to cover failures thrown before WebApplication.Build(). The bootstrap logger used during host construction and the application’s configured logging providers have different initialization boundaries, so it is unclear whether every pre-build exception will reach the same file target as runtime logs.
The desired behavior is deployment-oriented: startup failures should remain diagnosable when console output is not retained. However, the file provider’s path and permissions are deployment constraints, while environment overrides can change the effective minimum level from the value shown in appsettings.json. Behavior should be checked against the exact runtime and hosting model rather than inferred from .NET Framework or .NET Core 3.1 defaults.
A controlled pre-build failure with console and file outputs compared would establish the actual capture boundary without treating configuration presence as proof of delivery.
Open questions
- Should exceptions raised before
WebApplication.Build()be guaranteed to reach the configured file provider, or is console/bootstrap capture the intended contract? - Which runtime and hosting combinations should be covered by a regression test for this boundary?