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

DailyRollingFileAppender should roll if program doesn't run at rolling time

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • None
    • 0.10.0
    • Appender
    • None

    Description

      A DailyRollingFileAppender is only rolling the log file if the program is currently running.
      Example log4cxx.properties:
      log4j.appender.file = org.apache.log4j.DailyRollingFileAppender
      log4j.appender.file.datePattern='.'yyyy-MM-dd

      with this configuration, the log file will only be rolled if the program is running at midnight.

      This behaviour can be changed very easily:

      file: timebasedrollingpolicy.cpp lines 107-111:
      ---------------------------------------------------------------
      apr_time_t n = apr_time_now();
      nextCheck = ((n / APR_USEC_PER_SEC) + 1) * APR_USEC_PER_SEC;

      LogString buf;
      ObjectPtr obj(new Date);
      ---------------------------------------------------------------

      changed to:
      ---------------------------------------------------------------
      apr_time_t n = apr_time_now();
      nextCheck = ((n / APR_USEC_PER_SEC) + 1) * APR_USEC_PER_SEC;

      File currentFile(currentActiveFile);

      LogString buf;
      ObjectPtr obj(new Date(currentFile.exists(pool) ? currentFile.lastModified(pool) : n));
      ---------------------------------------------------------------

      I don't know if there is a better solution - this one works for me.

      Attachments

        Activity

          People

            carnold@apache.org Curt Arnold
            pontomedon Lukas Rössler
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - 0.25h
                0.25h
                Remaining:
                Remaining Estimate - 0.25h
                0.25h
                Logged:
                Time Spent - Not Specified
                Not Specified