Dispatch an Event when the a user logs I was looking into the new Events system for Drupal 8 and there's something I haven't been able to figure out.

I need to dispatch an event when a user logs something to the watchdog table using the new logging API.

// Logs a notice
\Drupal::logger('system')-&gt;notice($message);
// Logs an error
\Drupal::logger('system')-&gt;error($message);


https://www.drupal.org/docs/8/api/logging-api/overview

I already define a new Event in a custom module but I don't know what needs to be created so when a module logs/adds information to the watchdog table using the code above my event gets triggered.

Thanks
Once you get the event working, all you have to do is create an instance of the Logger Class in the Logger folder inside your module.

In here:
 /drupal_root/web/module/custom/my_module/src/Logger

And the class will be something like:

namespace Drupal\my_module\Logger;


use Drupal\Core\Logger\RfcLoggerTrait;
use Psr\Log\LoggerInterface;

class SendToEmail implements LoggerInterface {

  use RfcLoggerTrait;

  /**
   * Logs with an arbitrary level.
   *
   * @param mixed $level
   * @param string $message
   * @param array $context
   *
   * @return void
   */
  public function log($level, $message, array $context = []) {
    //Building the parameters for the email
    $params['level'] = $level;
    $params['message'] = $message;
    $params['context'] = $context;
    $this-&gt;sendEmail($params);
  }

  /**
   * @param array $params
   *
   * @return null
   */
  public function sendEmail($params = array()){
    //Variable declaration
    $module = 'my_module';
    $key = 'my_module_message';
    $to = "email@email.com";
    $from = "email@email.com";
    $language_code = \Drupal::service('language_manager')-&gt;getDefaultLanguage()-&gt;getId();
    $send_now = TRUE;

   $mail = \Drupal::service('plugin.manager.mail')-&gt;mail($module, $key, $to, $language_code, $params, $from, $send_now);
    return $mail;
  }
}