Brief introduction:
As the base component, the log component is used by other components and middleware, and it provides a unified programming model that does not need to know where the log is ultimately recorded, just call it.
The use of the method is simple, through the dependency injection Ilogfactory (Createlogger method) or Ilogger<t> object, get a ILogger object, Different levels of logging are then recorded through various extension methods of the ILogger, which are called the log method.
SOURCE Analysis:
Summarize:
The log component is actually the application of the factory pattern, but it has been improved, and Loggerfactory returns a logger object each time, and the Logger object contains a collection of all the ILogger objects that really want to work, forming an appearance pattern.
Follow but do not rigidly adhere to the design pattern, flexible and changeable techniques, it is worth learning!
ASP. NET core Source fragrance: Logging Components