Logging

\Drupal::logger('module_name')->notice('Message');
\Drupal::logger('module_name')->warning('Message');
\Drupal::logger('module_name')->error('Message');
  • D.O. Documentation page: interface LoggerInterface
  • module_name can be any string, using the module name is the common practice
  • HTML in message string is ok
  • Don’t use translate function (t)