[Blazor Server] Ability to have scoped logger
- Dominant language
- C#
- Stars
- 38.4k
- Forks
- 10.9k
- Avg merge
- 2d 6h
- Merged PRs (30d)
- 290
Description
Hello guys, In my blazor server app i would like to Inject some scoped services in my logger to trace some client information like circuitId (or other scoped data which allow me to identify the client). Otherwise it will be a mess in my logs, I will not be able to attach an exception to a specific client.
I already read here its a bad idea to have a scoped logger, however i really need this features, so i try with this :
````
services.AddScoped();
services.Add(ServiceDescriptor.Scoped(typeof(ILogger<>), typeof(MyLogger<>)));
````
However i have this error at startup
````
Cannot resolve scoped service 'Microsoft.Extensions.Logging.ILogger`1[Microsoft.AspNetCore.Hosting.WebHost]' from root provider.'
````
So the question, is it something can be achieved now ? (even if its dirty) or there is no way i can retrieve scoped information from the logger ?
thanks !
Contributor guide
Assessment
This issue has not been assessed yet.