Try Below Code:
Check LoggerInterface to debug
<?php
namespace Custom\Module\Observer;
use \Magento\Framework\Event\ObserverInterface;
use \Magento\Framework\Event\Observer;
class Index implements ObserverInterface
{
protected $logger;
public function __construct(
\Psr\Log\LoggerInterface $logger
) {
$this->logger = $logger;
}
public function execute(Observer $observer)
{
$order = $observer->getEvent()->getOrder();
// shipping address
$shippingAddress = $order->getShippingAddress();
$city = $shippingAddress->getCity();
$country = $shippingAddress->getCountryId();
$this->logger->info("shippingAddress=>".$country."<");
$this->logger->info("shippingAddress=>".$city."<");
}
}
Log print below path:-
../var/log/system.log
I hope so it's use full.