We are migrating a .NET Framework application(MVC) to a .NET Core 3 application (MVC). We have a scenario as follows:
Flow 1: ClassX instantiated by ControllerA
Flow 2: ClassX instantiated by ClassY instantiated by ClassZ instantiated by ClassD instantiated by Controller B
(ControllerA and ControllerB are part of the MVC Project. Classes X, Y, Z, D are part of a class library referenced by the MVC project. )
In the old .NET Framework project, log4net was used and static ILog objects were created in every class using LogManager.GetLogger. But ASP.NET Core uses DI principle. So from my understanding, the ILoggerFactory is injected into the Controllers A and B at Startup time. The loggerFactory can be passed from ControllerB to the ClassX, from ClassX to ClassY and so on, in Flow 2.
Only ClassX needs logging and not the other classes Y, Z and D in Flow 2.
Is there an alternative approach for doing logging with ILogger in this scenario, without changing the intermediate class constructors(Y, Z, D)?