0

How I can create my own custom log file in magento2 ?

For example, I have some variable which wants to log in a custom file. I found a solution for only existing log file like system.log, debug.log but I want new custom log file to log my variable.

2
  • $writer = new \Zend\Log\Writer\Stream(BP . '/var/log/mylog.log'); $logger = new \Zend\Log\Logger(); $logger->addWriter($writer); $logger->info("Your comment ".$variables);
    – Manish
    May 7, 2016 at 11:05
  • I think the right duplicate question/answer is here: magento.stackexchange.com/questions/75935/… Jun 30, 2017 at 8:14

1 Answer 1

0

For logging OR creating log file, you should use class "Magento\Framework\Logger\Monolog".

For more see here : http://inchoo.net/magento-2/magento-2-logging/

Not the answer you're looking for? Browse other questions tagged or ask your own question.