Uploaded image for project: 'CiviCRM'
  1. CiviCRM
  2. CRM-16321

CiviCRM log rotation overwrites existing file if log reaches 256M within a day

    Details

    • Type: Bug
    • Status: Done/Fixed
    • Priority: Minor
    • Resolution: Fixed/Completed
    • Affects Version/s: 4.4.14
    • Fix Version/s: 4.6.3
    • Component/s: Core CiviCRM
    • Labels:
      None
    • Documentation Required?:
      None

      Description

      The CiviCRM log file, files/civicrm/ConfigAndLog/CiviCRM.blah.log, is rotated monthly or when it reaches 256M, whichever happens first. It is then renamed with a date suffix, which is made up as follows:

      date('Ymdhs', mktime(0, 0, 0, date("m") - 1, date("d"), date("Y"))

      So this consists of the year, the previous month, the date, midnight in 12-hour format (12) and 00 seconds. E.g. here's one that was renamed at 11:44 today:

      rw-rr- 1 www-data www-data 257M Apr 20 11:44 CiviCRM.blah.log.201503201200

      If the log reaches 256M within a day (obviously it shouldn't in normal usage but we've come across this happening, due to an extension doing very verbose logging), then because the date suffix doesn't include a time, the renaming overwrites any existing log file from the same day.

      To avoid this, the date suffix needs to include the time. I suggest we also use the current month rather than previous month, as the latter only makes sense if the log is rotated monthly.

        Attachments

          Activity

            People

            • Assignee:
              kurund Kurund Jalmi
              Reporter:
              davej Dave Jenkins
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: