Magento 2 Write Messages Log file

Follow the below steps to write messages to log file.

1) Declare a variable.

protected $logger;

2) Initialize object

public function __construct(\Psr\Log\LoggerInterface $logger) {
$this->logger = $logger;

3) Now you can log the message as follows



Leave a Reply

Your email address will not be published. Required fields are marked *