title: log4net with DI Simple Injector
body: <p>I am trying to use Simple Injector ( + integration MVC) v 2.5.2. for an MVC 4 Application and I need to track/log performance (execution) as well(by log4net module). Current implementation (during runtime) creates log4net file in specified path but did not write any line of text into it (when I debug it everything went with no error to the end of <em>_logger.Info("message")</em> ). </p>
  
  <p>Does anyone try to use Simple Injector DI for log4net? </p>
  
  <p>The way how I've registered log4net module is:</p>
  
  <pre><code>public static class LoggingModule
  {
      public static void RegisterServices(Container container)
      {
          string log4NetConfigFile = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "log4net.config");
          log4net.Config.XmlConfigurator.ConfigureAndWatch(new FileInfo(log4NetConfigFile));
          var logger = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
          container.RegisterSingle(logger);
  
      }
  }
  </code></pre>
  
  <p>And in Global.asax</p>
  
  <pre><code>LoggingModule.RegisterServices(container);
  </code></pre>
  
  <p>Log4net configuration file looks like so (I dont think there is any problem):</p>
  
  <pre><code>&lt;log4net&gt;
    &lt;appender name="PerformanceLogFile" type="log4net.Appender.RollingFileAppender" &gt;
    &lt;param name="File" value="..\Performance\PricingManager" /&gt;
    &lt;param name="AppendToFile" value="true" /&gt;
    &lt;param name="RollingStyle" value="Date" /&gt;
    &lt;param name="DatePattern" value="_yyyy-MM-dd.lo\g" /&gt;
    &lt;param name="MaxSizeRollBackups" value="10" /&gt;
    &lt;param name="StaticLogFileName" value="false" /&gt;
    &lt;layout type="log4net.Layout.PatternLayout"&gt;
      &lt;param name="ConversionPattern" value="%m%n"/&gt;
    &lt;/layout&gt;
    &lt;filter type="log4net.Filter.LevelRangeFilter"&gt;
      &lt;param name="LevelMin" value="INFO" /&gt;
      &lt;param name="LevelMax" value="FATAL" /&gt;
    &lt;/filter&gt;
    &lt;/appender&gt;
    &lt;logger name="SoftTech.PricingEngine.PricingService.PerformanceStatisticLoggerWithAPI"&gt;
      &lt;level value="ALL" /&gt;
      &lt;appender-ref ref="PerformanceLogFile" /&gt;
    &lt;/logger&gt;
  &lt;/log4net&gt;
  </code></pre>
  
  <p>And to turn on/off logging I've been using:</p>
  
  <pre><code>private static void RegisterIPerformanceStatisticLogger(Container container)
      {
          if (ShouldLogPerformance())
          {
              container.Register&lt;IPerformanceStatisticLogger, PerformanceStatisticLogger&gt;(WebLifestyle); 
          }
          else
          {
              // do nothing
              container.Register&lt;IPerformanceStatisticLogger, DisabledPerformanceStatisticLogger&gt;(WebLifestyle); 
          }
      }
  </code></pre>
  
  <p>And PerformanceStatisticLogger or DisablePerformanceStatisticLogger sets </p>
  
  <pre><code>IsLoggingEnabled = true; // | false
  IsAPITraceEnabled = false; // | true
  </code></pre>
  
  <p>What I am doing wrong? Seems to me the problem of the way of injection.
  Thanks for any advice</p>