dotnet / dotnet/AspNetCore.Docs
W3CLogger documentation leads to an error and does not explain where the logs can be found
- Dominant language
- C#
- Stars
- 13.1k
- Forks
- 24.6k
- Avg merge
- 1d 3h
- Merged PRs (30d)
- 97
Description
### Description
When following the current version of the `W3CLogger` docs, it appears that one can enable W3C logging with just the following line:
```csharp
app.UseW3CLogging();
```
However, this causes the following error during startup:
```
crit: Microsoft.AspNetCore.Hosting.Diagnostics[6]
Application startup exception
System.InvalidOperationException: Unable to resolve service for type 'Microsoft.AspNetCore.HttpLogging.W3CLogger' while attempting to activate 'Microsoft.AspNetCore.HttpLogging.W3CLoggingMiddleware'.
at Microsoft.Extensions.Internal.ActivatorUtilities.ConstructorMatcher.CreateInstance(IServiceProvider provider)
at Microsoft.Extensions.Internal.ActivatorUtilities.CreateInstance(IServiceProvider provider, Type instanceType, Object[] parameters)
at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.ReflectionMiddlewareBinder.CreateMiddleware(RequestDelegate next)
at Microsoft.AspNetCore.Builder.ApplicationBuilder.Build()
at Microsoft.AspNetCore.Builder.ApplicationBuilder.Build()
at Microsoft.AspNetCore.Hosting.GenericWebHostService.StartAsync(CancellationToken cancellationToken)
```
It is not clearly stated that `builder.Services.AddW3CLogging(...)` is actually necessary like in the `HTTP Logging` docs. Additionally, the documentation does not specify where users can find the logs when using the default configuration.
### Page URL
https://learn.microsoft.com/en-us/aspnet/core/fundamentals/w3c-logger/?view=aspnetcore-8.0
### Content source URL
https://github.com/dotnet/AspNetCore.Docs/blob/main/aspnetcore/fundamentals/w3c-logger/index.md
### Document ID
13e1469d-48c9-5212-27bb-2869dcbbe2a8
### Article author
@wtgodbe
Contributor guide
Assessment
This issue has not been assessed yet.