Uploaded image for project: 'Log4net'
  1. Log4net
  2. LOG4NET-640

minimum achieved date roll is minute



    • Type: Bug
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 2.0.8
    • Fix Version/s: None
    • Component/s: Appenders
    • Labels:
    • Environment:
      Windows10, Development under Visual Studio, Code in C# .net 4.5


      Issue with RollingFileAppender while running log4net 2.0.8.
      I set it to roll on both file size and date (rollingStyle Composite). I am setting a datePattern in order to roll every second. : "dd-MM-yyy_HHmmss".
      However the roll I get is down to the minute. I think my pattern is right, as the pattern in the file name correctly is applied down to the second, however the roll only happens on the next full minute. I basically get the same result as if I was using datePattern "dd-MM-yyy_HHmm"

      Here is my configuration for the appender : 
      <appender name="RollingLogFileAppenderDebug" type="log4net.Appender.RollingFileAppender">
      <file type="log4net.Util.PatternString" value="%property{LogFilePath}Prog.csv" />
      <appendToFile value="true" />
      <rollingStyle value="Composite" />
      <datePattern value="dd-MM-yyy_HHmmss" />
      <PreserveLogFIlenameExtension value="true" />
      <maxSizeRollBackups value="100" />
      <ImmediateFlush value="true"/>
      <maximumFileSize value="2MB" />
      <staticLogFileName value="false" />
      <layout type="log4net.Layout.PatternLayout">
      <header value="[Date], [Time], [Thread], [Component], [Group], [Purpose], [Msg] "/>
      <footer value="[Date], [Time], [Thread], [Component], [Group], [Purpose], [Msg] "/>
      <conversionPattern value="%d

      {[dd/MM/yyyy], [HH:mm:ss.fff]}

      , [%thread], %message%newline" />

      And I get files something as follow:

      • Prog.11-01-2020_004752.csv
      • Prog.11-01-2020_004752.1.csv
      • Prog.11-01-2020_004752.2.csv
      • Prog.11-01-2020_004800.csv
      • Prog.11-01-2020_004800.1.csv
      • Prog.11-01-2020_004800.2.csv
      • Prog.11-01-2020_004900.csv
      • Prog.11-01-2020_004900.1.csv
      • Prog.11-01-2020_004900.2.csv

      So I started at 00h47m52s which created a log file which rolled because of max size reached twice, then it rolled again on the next full minute at 00h48m00s (which rolled because of max size reached twice) and at 00h49m00s, 00h50m00s, etc.  

      I am confused that my datePattern is correctly recognised as far as the naming of the file at time of creation is concerned, yet it does not roll at the next second the way it does at the nearest minute, hour, day.





            • Assignee:
              cuisquare Nicolas Vecchione
            • Votes:
              0 Vote for this issue
              2 Start watching this issue


              • Created: