title: How do I effectively design my application where most classes depend on ILogger?
body: <p>How can I pull objects from the container that are transient in nature? Do I have to register them with the container and inject in the constructor of the needing class? Injecting everything into the constructor doesn't feel good. Also just for one class I don't want to create a <code>TypedFactory</code> and inject the factory  into the needing class.</p>
  
  <p>Another thought that came to me was "new" them up on need basis. But I am also injecting a <code>Logger</code> component (through property) into all my classes. So if I new them up, I will have to manually instantiate the <code>Logger</code> in those classes. How can I continue to use the container for ALL of my classes?</p>
  
  <p><em><strong>Logger injection:</em></strong> Most of my classes have the <code>Logger</code> property defined, except where there is inheritance chain (in that case only the base class has this property, and all the deriving classes use that). When these are instantiated through Windsor container, they would get my implementation of <code>ILogger</code> injected into them.</p>
  
  <pre><code>//Install QueueMonitor as Singleton
  Container.Register(Component.For&lt;QueueMonitor&gt;().LifestyleSingleton());
  //Install DataProcessor as Trnsient
  Container.Register(Component.For&lt;DataProcessor&gt;().LifestyleTransient());
  
  Container.Register(Component.For&lt;Data&gt;().LifestyleScoped());
  
  public class QueueMonitor
  {
      private dataProcessor;
  
      public ILogger Logger { get; set; }
  
      public void OnDataReceived(Data data)
      {
          //pull the dataProcessor from factory    
          dataProcessor.ProcessData(data);
      }
  }
  
  public class DataProcessor
  {
      public ILogger Logger { get; set; }
  
      public Record[] ProcessData(Data data)
      {
          //Data can have multiple Records
          //Loop through the data and create new set of Records
          //Is this the correct way to create new records?
          //How do I use container here and avoid "new" 
          Record record = new Record(/*using the data */);
          ...
  
          //return a list of Records    
      }
  }
  
  
  public class Record
  {
      public ILogger Logger { get; set; }
  
      private _recordNumber;
      private _recordOwner;
  
      public string GetDescription()
      {
          Logger.LogDebug("log something");
          // return the custom description
      }
  }
  </code></pre>
  
  <p>Questions:</p>
  
  <ol>
  <li><p>How do I create new <code>Record</code> object without using "new"?</p></li>
  <li><p><code>QueueMonitor</code> is <code>Singleton</code>, whereas <code>Data</code> is "Scoped". How can I inject <code>Data</code> into <code>OnDataReceived()</code> method?</p></li>
  </ol>