Christian
Christian

Reputation: 2282

ILoggerFactory or ILoggerProvider: Which interface should I pass to classes that want to log something?

I want to use Microsoft.Extensions.Logging. I'm confused about which interface I should pass to a class/method which wants to log something: ILoggerFactory or ILoggerProvider. From the documentation and some tutorials I found it seems that I should ILoggerFactory. However, this interface contains a method AddProvider. This would give the class/method the ability to add a Provider, which is something I don't want a class to be able to do. ILoggerProvider has a simpler interface and allows only to create loggers, but from the documentation it seems that this is not the right one. As I understand it, it is only for abstracting logging "sinks". Which one is right?

Upvotes: 0

Views: 21

Answers (0)

Related Questions