C
C#2y ago
Simon

❔ Fire and forget, do I need a new logger?

I'm working on a small fire & forget background task initiated from asp.net. Essentially following this: https://learn.microsoft.com/en-us/aspnet/core/fundamentals/best-practices?view=aspnetcore-6.0#do-not-capture-services-injected-into-the-controllers-on-background-threads I am creating a new scope & requesting a new dbcontext. The question I have is: I want to do some logging as well, do I need to request a new ILogger/ILoggerFactory from the scope.ServiceProvider or can I use the ILogger that is DI'd to the Controller?
2 Replies
JakenVeina
JakenVeina2y ago
ILoggers are singleton, so you should be fine to use the same one
Accord
Accord2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server