No option to disable logging of Submission operations

Created on 16 June 2022, almost 3 years ago
Updated 8 April 2024, about 1 year ago

Currently, there is no option to disable the logging of Submission operations, even though there is a “Log submission events“ checkbox in the Webform settings.

Looking at the code, specifically WebformSubmissionStorage::doPostSave, it does check this setting, but if it's disabled it goes into the else and still logs data, just on another channel. The checkbox in the settings would indicate you can turn on/off the logging. Besides, there is a dedicated submodule for more extensive logging if required. With sites that contain a large amount of Webforms and Submissions, there are also many messages in the logs, even when one does not want them there. I propose that the second part in the else statement gets removed so that logging is only done when explicitly enabled, which is why I assume the checkbox is there.

if ($webform->hasSubmissionLog()) {
  // Log webform submission events to the 'webform_submission' log.
  $context = [
    '@title' => $entity->label(),
    'link' => ($entity->id()) ? $entity->toLink($this->t('Edit'), 'edit-form')->toString() : NULL,
    'webform_submission' => $entity,
  ];
  switch ($entity->getState()) {
    ...
  }
  $this->loggerFactory->get('webform_submission')->notice($message, $context);
}
elseif (!$webform->getSetting('results_disabled')) {
  // Log general events to the 'webform'.
  switch ($entity->getState()) {
    ...
  }
  if ($message) {
    $context = [
      '@id' => $entity->id(),
      '@title' => $entity->label(),
      'link' => ($entity->id()) ? $entity->toLink($this->t('Edit'), 'edit-form')->toString() : NULL,
    ];
    $this->loggerFactory->get('webform')->notice($message, $context);
  }
}
Feature request
Status

Closed: won't fix

Version

6.2

Component

Code

Created by

🇸🇮Slovenia jzavrl

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇨🇦Canada bisonbleu

    I think there's a genuine use case where disabling the loggers or having a quiet/not-so-verbose mode would be nice and it's during migrations.

    When importing/rolling-back webform submission in terminal, you get a notice for each submission. That means if you've got 50k submissions you will get 50k notices which slows the whole process down and sometimes sets your cpu on fire ;-)

    [notice] Deleted Webform Application: Submission #17256.
    [notice] Deleted Webform Self Service: Submission #17261.
    [notice] Deleted Webform Application: Submission #17266.
    [notice] Deleted Webform Application: Submission #17271.
    [notice] Deleted Webform Application: Submission #17276.
    [notice] Deleted Webform Application: Submission #17281.
    [notice] Deleted Webform Application: Submission #17286.
    [notice] Rolled back 3444 items - done with 'd7_webform_submission'
    …
  • 🇨🇦Canada bisonbleu

    There's a patch that does just that here: [3059072], courtesy of @jrockowitz himself :^)

  • Yes, however, as stated earlier in #10

    the module is still left with a on/off checkbox, which basically does nothing

    Even if we use a patch, there's still the issues mentioned in #10 to fix.

  • 🇨🇦Canada bisonbleu

    I agree. The patch is just one small step - hopefully in the right direction…

  • Status changed to Closed: won't fix about 1 year ago
  • 🇺🇸United States jrockowitz Brooklyn, NY

    This issue should be addressed via the patch, custom code or dedicated contributed module.

Production build 0.71.5 2024