Explicit resolving of ILog in Autofac when using with Log Injection Module

前端 未结 3 2238
一向
一向 2021-01-01 04:15

I use the following code in order to register log4net for all the classes that need it.

public class LogInjectionModule : Module
{
    private readonly strin         


        
3条回答
  •  说谎
    说谎 (楼主)
    2021-01-01 04:35

    nemesv's answer resolved the issue for me.

    Though, I had to spend some more time getting it to work after using the RegisterType approach, as I was missing the below:

    config.Filters.AddRange(config.DependencyResolver.GetServices(typeof(IExceptionFilter)).Select(o => o as IExceptionFilter));
    

    Just adding mentioning it here, if other's have forgotten to configure the filter in the first place.

提交回复
热议问题