Uploaded image for project: 'Log4cxx'
  1. Log4cxx
  2. LOGCXX-464

TimeBasedRollingPolicy should append as configured on rollover

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 0.10.0
    • Fix Version/s: 0.11.0
    • Component/s: Appender
    • Labels:
      None
    • Environment:
      Win32, Linux

      Description

      I'm using log4cxx 0.10.0 configured through xml to use a RollingFileAppender that rolls/triggers using a TimeBasedRollingPolicy.

      • The append property on the RollingFileAppender is true.
      • The FileNamePattern of the TimeBasedRollingPolicy is set to use the following pattern:
        %d{yyyyMMdd.HH}.log

      This setup I use in an embedded system that is not directly connected to the internet and has no battery powered rtc. This means that the system time is always 1970-01-01 01:00:00 at boot, normally time is synchronized by the user after boot.

      In this case the following situation can occur:

      1. Current time is 2016-04-05 15:20:00, my application is logging to
        20160405.15.log
      2. User restarts the system, time is now 1970-01-01 01:00, my application starts at boot and starts logging to
        19700101.01.log
      3. User synchronizes time to 2016-04-05 15:25:00. Now the application truncates
        20160405.15.log

        and start writing logs to it.

      I've traced the cause of this down to 1 line in timebasedrollingpolicy.cpp, in the end of ::rollover:

        return new RolloverDescription(
          nextActiveFile, false, renameAction, compressAction);
      

      In this line append is hardcoded to false, instead of using the append property.

        Attachments

          Activity

            People

            • Assignee:
              tschoening Thorsten Schöning
              Reporter:
              mbuijs Martijn Buijs
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: