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

后端 未结 3 2011
無奈伤痛
無奈伤痛 2021-02-20 06:45

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:28

    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");
    

提交回复
热议问题