You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
description: Learn about the breaking change in ASP.NET Core 8.0 where HTTP logging middleware now requires AddHttpLogging to be called on app startup.
4
+
ms.date: 11/14/2023
5
+
---
6
+
# HTTP logging middleware requires AddHttpLogging
7
+
8
+
ASP.NET Core HTTP logging middleware has been updated with extra functionality. The middleware now requires services registered with <xref:Microsoft.Extensions.DependencyInjection.HttpLoggingServicesExtensions.AddHttpLogging%2A>.
9
+
10
+
## Version introduced
11
+
12
+
ASP.NET Core 8.0
13
+
14
+
## Previous behavior
15
+
16
+
Previously, HTTP logging could be used by calling only <xref:Microsoft.AspNetCore.Builder.HttpLoggingBuilderExtensions.UseHttpLogging%2A>:
17
+
18
+
```csharp
19
+
varbuilder=WebApplication.CreateBuilder(args);
20
+
21
+
varapp=builder.Build();
22
+
app.UseHttpLogging();
23
+
app.MapGet("/", () =>"Hello World!");
24
+
app.Run();
25
+
```
26
+
27
+
## New behavior
28
+
29
+
If <xref:Microsoft.Extensions.DependencyInjection.HttpLoggingServicesExtensions.AddHttpLogging%2A> is not called on app startup, ASP.NET Core throws an informative error:
30
+
31
+
> 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'.
32
+
33
+
## Type of breaking change
34
+
35
+
This change is a [behavioral change](../../categories.md#behavioral-change).
36
+
37
+
## Reason for change
38
+
39
+
Additional features were added to the HttpLogging middleware which are registered (and configurable) via the <xref:Microsoft.Extensions.DependencyInjection.HttpLoggingServicesExtensions.AddHttpLogging%2A> method.
40
+
41
+
## Recommended action
42
+
43
+
Ensure that <xref:Microsoft.Extensions.DependencyInjection.HttpLoggingServicesExtensions.AddHttpLogging%2A> is called at application startup.
0 commit comments