Skip to main content

Drupal watchdog

Creating a message log using Drupal watchdog.

 

Simple log

// Logs a notice
\Drupal::logger('my_module')->notice($message);
// Logs an error
\Drupal::logger('my_module')->error($message);

 

Adding a layer of complexity to the log

public function submitForm(array &$form, FormStateInterface $form_state) {
    $entity = $this->getEntity();
    $entity->delete();

Subscribe to logging