Home autofac wiring Type to my logger
Reply: 0

autofac wiring Type to my logger

user863
1#
user863 Published in June 19, 2018, 2:23 pm

I have a logger as follows:

public class Logger : ILogger
{ 
    private ILogger _logger;

    public Logger(Type type)
    { 
        _logger =  LogManager.CreateLogger(type);
    }
     .... removed

I am trying to build a log module:

public class LogModule : Autofac.Module
{       
    protected override void Load(ContainerBuilder builder)
    {
        const string propertyNameKey = "Autofac.AutowiringPropertyInjector.InstanceType";


        builder.RegisterType<Logger>().As<ILogger>();
        base.Load(builder);
    }
}

I have to find and inject the type into the Logger, something like this question is asking, but that question does property injection, i need ctor injection.

How can I get contextual logging, ie log per Type?

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.358699 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO