8

I have a property on my classes for logging service.

private ILogger logger = NullLogger.Instance;
public ILogger Logger
{
    get { return logger; }
    set { logger = value; }
}

And I have this in my component registration:

container.AddFacility<LoggingFacility>(x => new LoggingFacility(LoggerImplementation.Log4net));

However, Windsor doesn't seem to inject the Logger - am I missing something?

Chris Haines
  • 6,445
  • 5
  • 49
  • 62

1 Answers1

14

The lambda parameter for AddFacility is actually a creation callback (it gets called when the facility is created), not a factory.

Use this instead:

container.AddFacility("logging", new LoggingFacility(LoggerImplementation.Log4net, "path_to_log4net.config"));

BTW Windsor automatically injects property dependencies whenever it can.

Mauricio Scheffer
  • 98,863
  • 23
  • 192
  • 275