1: משיכת הקלאס
use Psr\Log\LoggerInterface;
2. הצהרה על המשתנה
/**
* @var LoggerInterface
*/
protected $logger;
3.שילוב בקונסטרקטור
public function __construct(
Context $context,
PageFactory $resultPageFactory,
CustomerImport $customerImport,
LoggerInterface $logger,
Cron $cronExecute
)
{
parent::__construct($context);
$this->resultPageFactory = $resultPageFactory;
$this->logger = $logger;
$this->customerImport = $customerImport;
$this->cronExecute = $cronExecute;
}
$this->logger->error('Customer Logged In, Customer Email: '.$customerEmail);
יוצג ב: public_html/var/log/system.log
שימוש בקונסטרקטור
\Magento\Framework\App\ObjectManager::getInstance()
->get(\Psr\Log\LoggerInterface::class)->error('v32423');