Activation error occured while trying to get instance of type LogWriter, key “”?

后端 未结 3 1436
长情又很酷
长情又很酷 2021-02-20 06:46

I have asp.net web site. I added reference of Microsoft.Practices.EnterpriseLibrary.Logging.dll to the site.

in web.cofig file, I defined like below.

3条回答
  •  爱一瞬间的悲伤
    2021-02-20 07:25

    This worked for me, with EL 6.0 and not using Unity

    Init Logger from web.config file, on Global.asax -> Application_Start

    var configSource = ConfigurationSourceFactory.Create();
    Logger.SetLogWriter(new LogWriterFactory(configSource).Create());
    

    Use logger on MVC controller

    Logger.Write("Hello", "General");
    

提交回复
热议问题