title: Log4net always generates a new file inside a Windows Service as a WCF Service
body: <p>Declaring my Logger:</p>
  
  <pre><code>private static readonly ILog Logging = LogManager.GetLogger(typeof(Service1));
  </code></pre>
  
  <p>My constructor:</p>
  
  <pre><code>public Service1()
  {
      InitializeComponent();
      InitializeLogging(@"c:\log\");
  }
  </code></pre>
  
  <p>And this is how I initialize my logger:</p>
  
  <pre><code>public static void InitializeLogging(String Path)
  {
      var patternLayout = new PatternLayout()
                          {
                              ConversionPattern = "%utcdate{yyyy-MM-dd HH:mm:ss.fff}"
                                                  + "|%level"
                                                  + "|%class"
                                                  + "|%method"
                                                  + "|%line"
                                                  + "|%timestamp"
                                                  + "|%message"
                                                  + "%newline"
                          };
  
      patternLayout.ActivateOptions();
  
      RollingFileAppender roller = new RollingFileAppender()
                                       {
                                           AppendToFile = true,
                                           File = Path,
                                           DatePattern = "yyyyMMdd HHmmss'.log'",
                                           Layout = patternLayout,
                                           StaticLogFileName = false,
                                           RollingStyle = RollingFileAppender.RollingMode.Date
                                       };
      roller.ActivateOptions();
  
      BasicConfigurator.Configure(roller);
  }
  </code></pre>
  
  <p>When the Windows Service isn't started, log4net generates a log file with one line of code, "service started". </p>
  
  <p>When a WCF method is called, log4net generates a new file with one line of log, always. And when the service is stopped, log4net writes in every file "service is stopped".</p>
  
  <p>One log file a day is enough :(</p>