Quantcast
Channel: ASP.NET Core
Viewing all articles
Browse latest Browse all 9386

Logger not working with type arguments

$
0
0

On an ASP.NET Core 1.1 Web API, when using ILogger in my controller, this works fine:

public class UsersController : Controller
{
    private readonly SharedDataContext _context;
    private readonly ILogger _logger;

    public UsersController(SharedDataContext context, ILoggerFactory logger)
    {
        _context = context;
        _logger = logger;
    }
}

but this:

public class UsersController : Controller
{
    private readonly SharedDataContext _context;
    private readonly ILogger<UsersController> _logger;

    public UsersController(SharedDataContext context, ILoggerFactory<UsersController> logger)
    {
        _context = context;
        _logger = logger;
    }
}

gives me this error:

The non-generic type 'ILoggerFactory' cannot be used with type arguments

Any ideas? Thanks...


Viewing all articles
Browse latest Browse all 9386

Trending Articles