GitHub user n1l opened a pull request:

    https://github.com/apache/log4net/pull/23

    fix bug with m_preserveLogFileNameExtension and m_staticLogFileName

    Hi! I think that I found a bug.
    
    This code is example to show you, that file rolling is not happening
    
    `class Program
      {
        public static void Main(string[] args)
        {
          var log = Logger.Create();
          for (int i = 0; i < 1000; i++)
          {
            log.Debug(Enumerable.Range(50, 50)
              .Select(x => x.ToString())
              .Aggregate(string.Empty, (x, y) => x + ' ' + y));
          }
    
        }
      }
      public class Logger
      {
        public Logger()
        {
        }
    
        public void AddAppender(IAppender appender)
        {
          Hierarchy hierarchy =
            (Hierarchy)LogManager.GetRepository();
    
          hierarchy.Root.AddAppender(appender);
        }
    
        static Logger()
        {
          Hierarchy hierarchy = (Hierarchy)LogManager.GetRepository();
          TraceAppender tracer = new TraceAppender();
          PatternLayout patternLayout = new PatternLayout();
    
          patternLayout.ActivateOptions();
    
          tracer.Layout = patternLayout;
          tracer.ActivateOptions();
          hierarchy.Root.AddAppender(tracer);
          RollingFileAppender roller = new RollingFileAppender();
          roller.StaticLogFileName = false;
          roller.Layout = patternLayout;
          roller.AppendToFile = true;
          roller.RollingStyle = RollingFileAppender.RollingMode.Composite;
          roller.DatePattern = "dd_MM_yyyy";
          roller.MaxSizeRollBackups = 2;
          roller.CountDirection = 1;
          roller.PreserveLogFileNameExtension = true;
          roller.MaximumFileSize = "10KB";
          roller.File = 
@"D:\Projects\Contrib\Work\LoggingTestApp\LOGS\mylog_.log";
          roller.ActivateOptions();
          hierarchy.Root.AddAppender(roller);
    
          hierarchy.Root.Level = Level.All;
          hierarchy.Configured = true;
        }
    
        public static ILog Create()
        {
          return LogManager.GetLogger("");
        }
      }`
    
    I fixed this, please review my code.
    Thanks.

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/n1l/log4net trunk

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/log4net/pull/23.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #23
    
----
commit 8558b95e75e5bc886078ceb81dc38e63ec31645c
Author: dvega <akasht...@gmail.com>
Date:   2016-02-29T17:10:40Z

    fix bug with m_preserveLogFileNameExtension and m_staticLogFileName set to 
true

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to