Answers.Body: <p>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 <code>TRUE</code> 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.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-03-31T03:18:47.747Z
Answers.Text: 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.
Answers.UserDisplayName: Martin_W
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-03-29T13:35:07.303Z
Answers.LastActivityDate: 2021-03-29T13:35:07.303Z
Answers.UserDisplayName: Jon G - Megaphone Tech
Body: <p>When enabling &quot;<a href="https://docs.civicrm.org/sysadmin/en/latest/setup/logging/" rel="nofollow noreferrer">detailed logging</a>&quot; 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 &quot;master&quot; site (with Civi domain ID 1)?</p>
  <p>I've noticed that in the <code>civicrm_setting</code> table, the <code>logging</code> setting is stored with the <code>domain_id</code>. And, in the CiviCRM admin UI, when logging is &quot;enabled&quot; on the site with domain ID 1, it still shows as &quot;disabled&quot; on other sites unless I explicitly &quot;enable&quot; it.</p>
  <p>Since logging works via insert/update/delete triggers on each DB table, I cannot see how logging could be &quot;enabled&quot; 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 <code>domain_id</code> value in the <code>civicrm_setting</code> table) is confusing, and I have not seen this documented elsewhere.</p>
  <p>I'm running WordPress multisite (v.5.4.4) and Civi 5.35.1.</p>
  <hr />
  <p><strong>Edit:</strong> Out of curiosity, I dug deeper and inspected the database triggers on the <code>civicrm_contact</code> table after first enabling logging on both the main (domain ID 1) site and a child site, and then again after disabling logging on <strong>only</strong> the child site.</p>
  <p>After enabling logging, there was a <code>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 ...</code> defined on the <code>civicrm_contact</code> table. And after disabling logging on <strong>only</strong> the child site, that trigger disappeared from the <code>civicrm_contact</code> table. So this seems to confirm that logging is <strong>not</strong> specific to a domain ID. But, I don't know whether or how the codebase uses the <code>@civicrm_disable_logging</code> variable. Through that variable, it looks like it would be possible to disable/bypass logging on a per-site basis!</p>
  <p>For the record, I enabled and disabled logging via the <code>wp cv</code> CLI rather than the UI using (e.g.):</p>
  <pre><code>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 
  </code></pre>
  <p>I did not test to see if changing settings in the UI behaves differently.</p>
  
Tags: <multisite><logging>
Title: When enabling logging/auditing for multisite (multi-domain), does it need to be enabled for each site/domain?
ThreadText: # When enabling logging/auditing for multisite (multi-domain), does it need to be enabled for each site/domain?
  
  (Asked by: username_0 on 2021-03-28)
  
  When enabling "[detailed logging](https://docs.civicrm.org/sysadmin/en/latest/setup/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.
  
  **Tags:** multisite, logging
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2021-03-29. Score: 1 | Accepted answer
  
  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.
  
  > **Comments:**
  > **username_0**: 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.  
  
  ---
  
  