How to inject ILogger to container from CMS 11

  • Updated

In the Breaking Changes in CMS 11, it is no longer supported to get an ILogger instance from the IOC container. But if your solution 

There is an alternative way is using LogManager to get ILogger Instance

But if you've recently upgrade your solution to CMS 11 and there is a lot of code using injected ILogger from IoC container. You don't want to change this, let use the below code 

public static void Configure(IContainer container)
x =>
x.Scan(y =>

x.For<ILogger>().AlwaysUnique().Use(context => LogManager.GetLogger(context.ParentType ?? context.RootType));