Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

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);
    }
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #instance #class #ilogger
ADD COMMENT
Topic
Name
2+6 =