Using Ninject to fill Log4Net Dependency

后端 未结 7 1252
天命终不由人
天命终不由人 2020-12-23 21:28

I use Ninject as a DI Container in my application. In order to loosely couple to my logging library, I use an interface like this:

public interface ILogger
         


        
7条回答
  •  一向
    一向 (楼主)
    2020-12-23 22:10

    maybe my answer is late but I'm using this format:

    private static void RegisterServices(IKernel kernel)
        {
            kernel.Bind()
                .ToMethod(c => LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType))
                .InSingletonScope();
        }
    

提交回复
热议问题