2

When enabling "detailed logging" for a multisite (multi-domain) installation, does logging actually need to be enabled for each domain ID? Or is it sufficient to enable logging only on the "master" site (with Civi domain ID 1)?

I've noticed that in the civicrm_setting table, the logging setting is stored with the domain_id. And, in the CiviCRM admin UI, when logging is "enabled" on the site with domain ID 1, it still shows as "disabled" on other sites unless I explicitly "enable" it.

Since logging works via insert/update/delete triggers on each DB table, I cannot see how logging could be "enabled" for one domain ID but not enabled for all other domain IDs. Nonetheless, the fact that the setting appears to be independent for each site (based on both the UI and on the domain_id value in the civicrm_setting table) is confusing, and I have not seen this documented elsewhere.

I'm running WordPress multisite (v.5.4.4) and Civi 5.35.1.


Edit: Out of curiosity, I dug deeper and inspected the database triggers on the civicrm_contact table after first enabling logging on both the main (domain ID 1) site and a child site, and then again after disabling logging on only the child site.

After enabling logging, there was a TRIGGER civicrm_contact_after_insert after insert ON civicrm_contact FOR EACH ROW BEGIN IF ( @civicrm_disable_logging IS NULL OR @civicrm_disable_logging = 0 ) THEN INSERT INTO ... defined on the civicrm_contact table. And after disabling logging on only the child site, that trigger disappeared from the civicrm_contact table. So this seems to confirm that logging is not specific to a domain ID. But, I don't know whether or how the codebase uses the @civicrm_disable_logging variable. Through that variable, it looks like it would be possible to disable/bypass logging on a per-site basis!

For the record, I enabled and disabled logging via the wp cv CLI rather than the UI using (e.g.):

wp cv api setting.create logging=1 --url=main.mydomain.org 
wp cv api setting.create logging=1 --url=childsite1.mydomain.org 
wp cv api setting.create logging=0 --url=childsite1.mydomain.org 

I did not test to see if changing settings in the UI behaves differently.

1 Answer 1

1

You're correct that logging is at the database level. It seems like a bit of a loophole that it can be enabled-disabled on a per-domain basis. I would set it to TRUE on all domains to avoid unexpected behavior, but my guess is you'll only have a problem if you disable it on one site and expect it to continue working on others.

1
  • Thanks Jon. It's of course quite tedious to navigate to the "Misc. settings" page on all of the child sites to turn logging "off" or "on" so they match across all sites--- when it's really a case of "last setting wins" across all sites. Confusing UI! I will suggest an improvement on the lab.civicrm.org repo.
    – Martin_W
    Commented Mar 31, 2021 at 3:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.