Specify dynamic method for interface resolution on type resolving in Autofac

175 views Asked by At

Many of my classes are accepting some ILogger interface.

This interface is implemented by a class that can accept the context it should log.

So in practice when passing ILogger, what I want to pass is new Logger(nameof(<type>), depending on the <type> we are currently resolving.

Can this be done in some sort in Autofac without specifically stating the contructor parameters for each type? since this is always the behavior I want to achieve when Autofac resolves ILogger injection parameter.

1

There are 1 answers

0
Mugen On BEST ANSWER

Found a formal example in Autofac documentation:

http://docs.autofac.org/en/latest/examples/log4net.html