I'm working on ASP .Net MVC5 project, I'm using ILogger interface inder Microsoft.Extensions.Logging and Unity framework for DI.
What I want is to inject ILogger into my project to use it in my controllers.
I installed Unity and Unity.MVC nuget packages in my project and I tried to inject ILogger like this :
public static void RegisterTypes(IUnityContainer container)
{
container.RegisterType(typeof(ILogger<>), typeof(Logger<>), (new HierarchicalLifetimeManager()));
}
My controller :
public class HomeController : Controller
{
private readonly ILogger _logger;
public HomeController(ILogger logger)
{
_logger = logger;
}
public ActionResult Index()
{
_logger.LogInformation("TEST log event message");
return View();
}
Always when I run the project I get this error :

ILogger<>while your controller is expecting the non-generic version. Did you try to simply registerLoggerasILogger?