I have a ASP.NET MVC 6 (beta-4) app.
public void ConfigureServices(IServiceCollection services)
{
// Logging
services.AddLogging();
// ...
}
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerfactory)
{
// Add the console logger.
loggerfactory.AddConsole(minLevel: LogLevel.Warning);
// ...
}
And I have a controller...
public class HomeController :
Controller
{
ILogger _logger;
public HomeController(ILogger logger)
{
_logger = logger;
}
// ...
}
But when I'm not getting the service registered correctly somehow: InvalidOperationException: Unable to resolve service for type 'Microsoft.Framework.Logging.ILogger' while attempting to activate 'HomeController'.
. What am I doing wrong with the registering the logger?