更新时间:2023-02-16 13:27:10
使用DI指定ILogger<T>
类型而不是Logger
,其中T
是使用记录器的类类型,因此NLog会知道该类.例如:
Using DI specify ILogger<T>
type instead of Logger
, where T
is the class type that uses the logger, so NLog will know about the class. For example:
public class TodoController : Controller
{
private readonly ILogger _logger;
public TodoController(ILogger<TodoController> logger)
{
_logger = logger;
}
}