Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

W3CLogger documentation leads to an error and does not explain where the logs can be found #33592

Open
bakku opened this issue Sep 12, 2024 · 0 comments

Comments

@bakku
Copy link

bakku commented Sep 12, 2024

Description

When following the current version of the W3CLogger docs, it appears that one can enable W3C logging with just the following line:

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants