Skip to content

Conversation

gewarren
Copy link
Contributor

@gewarren gewarren commented Sep 29, 2025

Addresses issue #370661 by adding documentation for the .NET 8 breaking change where UseHttpLogging() now requires calling AddHttpLogging() beforehand.

What changed

In .NET 8, the HTTP logging middleware was enhanced with additional functionality that requires service registration. Previously, developers could simply call:

app.UseHttpLogging();

Now they must also register the services:

builder.Services.AddHttpLogging();
app.UseHttpLogging();

Without the service registration, applications will fail with:

System.InvalidOperationException: Unable to resolve service for type 'Microsoft.Extensions.ObjectPool.ObjectPool`1[Microsoft.AspNetCore.HttpLogging.HttpLoggingInterceptorContext]' while attempting to activate 'Microsoft.AspNetCore.HttpLogging.HttpLoggingMiddleware'.

Changes made

  • Added: docs/core/compatibility/aspnet-core/8.0/httpLogging-addhttplogging-requirement.md - Complete breaking change documentation following the established format
  • Updated: docs/core/compatibility/toc.yml - Added TOC entry in the ASP.NET Core 8.0 section

The documentation follows the same pattern as other middleware requirement changes (like the rate limiting breaking change) and includes all standard sections: version information, previous/new behavior, breaking change type, reason for change, recommended action, and affected APIs.

Fixes #370661

Original prompt

This section details on the original issue you should resolve

<issue_title>[Breaking change]: Http logging in dotnet 8 doesn't work without call AddHttpLogging</issue_title>
<issue_description>### Description

In .NET 8 UseHttpLogging now requires calling AddHttpLogging beforehand.

Version

.NET 8

Previous behavior

Apps could call just app.UseHttpLogging(); to have HTTP logging activated.

New behavior

You need to call services.AddHttpLogging(); too now, otherwise your app with fail with an error.

System.InvalidOperationException: Unable to resolve service for type 'Microsoft.Extensions.ObjectPool.ObjectPool`1[Microsoft.AspNetCore.HttpLogging.HttpLoggingInterceptorContext]' while attempting to activate 'Microsoft.AspNetCore.HttpLogging.HttpLoggingMiddleware'.

Type of breaking change

  • Binary incompatible: Existing binaries might encounter a breaking change in behavior, such as failure to load or execute, and if so, require recompilation.
  • Source incompatible: When recompiled using the new SDK or component or to target the new runtime, existing source code might require source changes to compile successfully.
  • Behavioral change: Existing binaries might behave differently at run time.

Reason for change

Additional features were added to the HttpLogging middleware which are registered (and configurable) via the AddHttpLogging method.

Recommended action

Call services.AddHttpLogging() during host construction.

Feature area

ASP.NET Core

Affected APIs

No response


Associated WorkItem - 370661</issue_description>

Comments on the Issue (you are @copilot in this section)

@gewarren @BrennanConroy You can transfer this issue back to dotnet/docs, and as long as the details in the description are accurate, nothing else is needed to get the doc going.
Fixes #48064

💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.


Internal previews

📄 File 🔗 Preview link
docs/core/compatibility/8.0.md Breaking changes in .NET 8
docs/core/compatibility/aspnet-core/8.0/httplogging-addhttplogging-requirement.md HTTP logging middleware requires AddHttpLogging()
docs/core/compatibility/toc.yml docs/core/compatibility/toc

@gewarren gewarren requested a review from a team as a code owner September 29, 2025 22:37
@dotnetrepoman dotnetrepoman bot added this to the September 2025 milestone Sep 29, 2025
@gewarren gewarren enabled auto-merge (squash) September 30, 2025 00:08
Copy link
Member

@BillWagner BillWagner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This LGTM. Let's :shipit:

@gewarren gewarren merged commit 08cb49d into dotnet:main Sep 30, 2025
7 of 8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Breaking change]: Http logging in dotnet 8 doesn't work without call AddHttpLogging
4 participants