How to get events/observers in magento 2

You can do the same thing you did in Magento 1.x in the method \Magento\Framework\Event\Manager::dispatch().

but it's a difference. You don't have access to the logger.
You will have to inject an instance of the logger in the constructor.

protected $logger;

public function __construct(
    InvokerInterface $invoker, 
    ConfigInterface $eventConfig,
    \Psr\Log\LoggerInterface $logger
)
{
    $this->_invoker = $invoker;
    $this->_eventConfig = $eventConfig;
    $this->logger = $logger;
}

Then you can call in the dispatch method this:

$this->logger->info($message);

Instead of info you can use all the methods from \Psr\Log\LoggerInterface


Since this is for "quick debugging", you could avoid multiple edits by doing.

public function dispatch($eventName, array $data = [])
{
    $logger = \Magento\Framework\App\ObjectManager::getInstance()->get(\Psr\Log\LoggerInterface::class);
    $logger->info($eventName);
    ...

Location

/lib/internal/Magento/Framework/Event/Manager.php

@Marius answer is the correct solution.


In my case I can get list of all event by doing below changes which is very short cut like we do in mage.php file of magento1:

Note: I have only tested on magento2.1.1 version so I am not sure for any other version

\vendor\magento\framework\Event\Manager.php

public function dispatch

write below code to get all event in debug.log file after

$eventName = mb_strtolower($eventName); 

near to line 56

\Magento\Framework\App\ObjectManager::getInstance()->get('Psr\Log\LoggerInterface')->debug($eventName);