This is my code. The event is not getting triggerd after I place a new order.
app/code/Company/RalSurcharge/etc/frontend/events.xml (i also tried app/code/Company/RalSurcharge/etc/events.xml)
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
<event name="sales_order_place_before">
<observer name="company_ralsurcharge_sales_order_place_before" instance="Company\RalSurcharge\Observer\RalSurcharge2" />
</event>
</config>
app/code/Company/RalSurcharge/Observer/RalSurcharge2.php
<?php
namespace Company\RalSurcharge\Observer;
use \Magento\Framework\Event\ObserverInterface;
use \Magento\Framework\Event\Observer;
class RalSurcharge2 implements ObserverInterface
{
public function execute(Observer $observer)
{
$writer = new \Zend\Log\Writer\Stream(BP . '/var/log/observer.log');
$logger = new \Zend\Log\Logger();
$logger->addWriter($writer);
$logger->info("Hello from sales_order_place_before observer");
}
}