Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CIVICRM_LOG_FILE - Allow constant to specify the log-file name
Allow system administrators to define the file-naming convention for log files. This complements on civicrm#20109, which is a step toward logging more information to separate channels. The primary risk of directing channels to separate channels is that existing log-aggregators will not find them (e.g. they may expect a consolidated log file). This mitigate the risk by phasing-in the new filenames -- and allowing opt-ins/opt-outs. * For new deployments, the default is `CiviCRM.{{CHANNEL}}.{{HASH}}.log`. It should be expected that logs will be split into multiple channels/files, and that channels/files may come and go over time. * For sysadmins that want a single/predictable log, use `CiviCRM.{{HASH}}.log` or `CiviCRM.log`. * For existing deployments, the default is `CiviCRM.{{LEGACY_CHANNEL}}{{LEGACY_HASH}}log`. This will only produce files that match the old naming convention. New channels are consolidated under the blank channel-name. Before ------ Suppose you make these two log statements: ``` cv ev 'Civi::log()->info("default stuff"); Civi::log("ipn")->info("payment stuff");' ``` It will generate these two log files: ``` ~/bknix/build/dmaster/web/sites/default/files/civicrm/ConfigAndLog/CiviCRM.0123abcd0123abcd99999999.log ~/bknix/build/dmaster/web/sites/default/files/civicrm/ConfigAndLog/CiviCRM.ipn.0123abcd0123abcd99999999log ``` After ----- The behavior depends on on `CIVICRM_LOG_FILE`. Here are the log files produced by different configurations: ``` == Default on new deployments == define('CIVICRM_LOG_FILE', 'CiviCRM.{{CHANNEL}}.{{HASH}}.log'); ~/bknix/build/dmaster/web/sites/default/files/civicrm/ConfigAndLog/CiviCRM.ipn.0123abcd0123abcd99999999.log ~/bknix/build/dmaster/web/sites/default/files/civicrm/ConfigAndLog/CiviCRM.default.0123abcd0123abcd99999999.log == Default on old/unconfigured deployments == define('CIVICRM_LOG_FILE', 'CiviCRM.{{LEGACY_CHANNEL}}{{LEGACY_HASH}}log'); ~/bknix/build/dmaster/web/sites/default/files/civicrm/ConfigAndLog/CiviCRM.0123abcd0123abcd99999999.log == Use on combined log for everything == define('CIVICRM_LOG_FILE', '/tmp/my-log/CiviCRM.log'); /tmp/my-log/CiviCRM.log == Store logs in the normal `[civicrm.log]` folder, but with deep directories == define('CIVICRM_LOG_FILE', '[civicrm.log]/{{HASH}}/{{CHANNEL}}/{{YYYY-MM-DD}}.log'); ~/bknix/build/dmaster/web/sites/default/files/civicrm/ConfigAndLog/0123abcd0123abcd99999999/ipn/2021-04-27.log ~/bknix/build/dmaster/web/sites/default/files/civicrm/ConfigAndLog/0123abcd0123abcd99999999/default/2021-04-27.log == Store logs in an alternate part of the `[civicrm.private]` folder == define('CIVICRM_LOG_FILE', '[civicrm.private]/logging/{{HASH}}/{{CHANNEL}}/{{YYYY-MM-DD}}.log'); ~/bknix/build/dmaster/web/sites/default/files/civicrm/logging/0123abcd0123abcd99999999/ipn/2021-04-27.log ~/bknix/build/dmaster/web/sites/default/files/civicrm/logging/0123abcd0123abcd99999999/default/2021-04-27.log == Store logs in `/tmp` with long file names == define('CIVICRM_LOG_FILE', '/tmp/my-log/civicrm-{{HASH}}-{{CHANNEL}}-{{YYYY-MM-DD}}.log'); /tmp/my-log/civicrm-0123abcd0123abcd99999999-default-2021-04-27.log /tmp/my-log/civicrm-0123abcd0123abcd99999999-ipn-2021-04-27.log ``` You can verify this by running https://gist.github.com/totten/bd0df4478653330cf812bd481cb76ffc
- Loading branch information