title: Castle Windsor won't inject Logger in a property!
body: <p>I try to inject log4net in a ILogger property of my service class but the property is always NULL!</p>
  
  <p>I've seen this topic but it doesn't help me!</p>
  
  <p><a href="https://stackoverflow.com/questions/1058785/how-can-i-get-castle-windsor-to-automatically-inject-a-property">How can I get Castle Windsor to automatically inject a property?</a> </p>
  
  <p>this is Program.cs</p>
  
  <pre><code> CastleContainer.Instance
          .Install(
            new RepositoriesInstaller(),
            new PersistenceInstaller(),
            new LoggerInstaller(),
            new FormInstaller(),
            new ServiceInstaller()
  
            );
  
          FrmStart form1 = CastleContainer.Resolve&lt;FrmStart&gt;(new {Id="666" });
  </code></pre>
  
  <p>I use log4net.config external file and this is my installer:</p>
  
  <pre><code>public class LoggerInstaller : IWindsorInstaller
  {
      #region IWindsorInstaller Members
  
      public void Install(IWindsorContainer container, IConfigurationStore store)
      {
           container.AddFacility("logging", new LoggingFacility(LoggerImplementation.Log4net, "log4net.config"));
      }
  
      #endregion
  }
  </code></pre>
  
  <p>This is the class contains the property I want Windsor to inject:</p>
  
  <pre><code>public partial class FrmStart : Form
  {
      private EventService EventService;
  
      private ILogger logger = NullLogger.Instance;
      public ILogger Logger
      {
          get { return logger; }
          set { logger = value; }
      }
  
      public FrmStart(EventService eventService, string Id)
          : this()
      {
  
          Logger.Debug("xxx");
  
          this.EventService = eventService;
          this.id = Id;
      }
  </code></pre>
  
  <p>Note that "eventService" and "Id" in the constructor are correctly injected! 
  If I try to inject the Logger in the constructor it works and I've the Logger object:
  {log4net.Repository.Hierarchy.DefaultLoggerFactory+LoggerImpl}! :-(</p>
  
  <p>I've tried to create a public property for EventService and Windsor can inject it properly! So I think the problem is related only to the ILogger interface. </p>
  
  <p>I prepared a simple full-code example here:</p>
  
  <pre><code>using Castle.Core.Logging;
  using Castle.Facilities.Logging;
  using Castle.MicroKernel.Registration;
  using Castle.MicroKernel.SubSystems.Configuration;
  using Castle.Windsor;
  
  namespace IocTest
  {
  
  
  public class LoggerInstaller : IWindsorInstaller
  {
      public void Install(IWindsorContainer container, IConfigurationStore store)
      {
           container.AddFacility("logger", new LoggingFacility(LoggerImplementation.Log4net, "log4net.config"));
      }
  }
  public class LogicInstaller : IWindsorInstaller
  {
       public void Install(IWindsorContainer container, IConfigurationStore store)
      {
          container.Register(AllTypes.FromThisAssembly()
                              .Pick()
                              .If(t =&gt; t.Name.StartsWith("Logic"))
                              .Configure((c =&gt; c.LifeStyle.Transient)));
      }
  }
  
  class Program
  {
      static void Main(string[] args)
      {
          IWindsorContainer container = new WindsorContainer();
  
          container.Install(
          new LoggerInstaller(),
            new LogicInstaller()
            );
  
  
          LogicClass1 logic1 = container.Resolve&lt;LogicClass1&gt;();
          LogicClass2 logic2 = container.Resolve&lt;LogicClass2&gt;();
      }
  }
  
  public class LogicClass1
  {
      private ILogger logger = NullLogger.Instance;
      public ILogger Logger
      {
          get { return logger; }
          set { logger = value; }
      }
  
      public LogicClass1()
      {
          logger.Debug("Here logger is NullLogger!");
      }
  }
  
  public class LogicClass2
  {
      public LogicClass2(ILogger logger)
      {
          logger.Debug("Here logger is properly injected!");
      }
  }
  }
  </code></pre>
  
  <p>What's wrong?</p>