You state in your comment
.UseLoggerFactory(MyLoggerFactory) // Warning: Do not create a new ILoggerFactory instance each time
Are you giving an example of what not to do? or is your example usable as is?
LoggerFactory.Create should return a singleton, no?
⚠Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
Example usable as is. If you see definition of MyLoggerFactory then it is a static field which is initialized only once per class so everytime you initialize the context, it would be same logger factory. The comment specifically says that do not create new instance and pass here every time which using a static field solves.
LoggerFactory.Create should return a singleton, no?
Singleton/scoped is inside DI. This is outside of DI. Create method creates a logger factory and gives it back to user. There is no scoping. User needs to manage object themselves.
Most helpful comment
Example usable as is. If you see definition of MyLoggerFactory then it is a static field which is initialized only once per class so everytime you initialize the context, it would be same logger factory. The comment specifically says that do not create new instance and pass here every time which using a static field solves.
Singleton/scoped is inside DI. This is outside of DI. Create method creates a logger factory and gives it back to user. There is no scoping. User needs to manage object themselves.