How can I log(watchdog)?
There are many different types of logging, all called the same way as per the documentation:

\Drupal::logger('my_module')-&gt;alert($message);

\Drupal::logger('my_module')-&gt;info($message);

\Drupal::logger('my_module')-&gt;debug($message);


Just call this code anywhere in your module, if you want to register logmessage as a path you'll need to create my_module.routing.yml, etc.