Search code examples
c#asp.net-web-apilog4netsimple-injector

Simple Injector: RegisterConditional with log4net


I'm trying to get log4net to work with Simple Injector by following the advice from this answer. However, it appears that LogImpl now requires a constructor with an ILogger as a parameter:

There is no argument given that corresponds to the required formal parameter 'logger' of 'LogImpl.LogImpl(ILogger)'.

image

Is there anyone that uses another method to accomplish this?


Solution

  • There seems to be a breaking change in the LogImpl class. You can change your Log4NetAdapter<T> class to the following:

    public sealed class Log4NetAdapter<T> : LogImpl
    {
        public Log4NetAdapter() : base(LogManager.GetLogger(typeof(T)).Logger) { }
    }