c# instance class with ilogger

70

c# instance class with ilogger -

public class MyController
{
    private readonly ILogger _logger;
    private readonly ILoggerFactory _loggerFactory;
    
    public MyController(ILogger<MyController> logger, ILoggerFactory loggerFactory)
    {
        _logger = logger;
        _loggerFactory = loggerFactory;
    }

    public ActionResult List()
    {
        ILogger<MyModel> modelLogger = _loggerFactory.CreateLogger<MyModel>();
        MyModel model = new MyModel(modelLogger);
    }
}

Comments

Submit
0 Comments