How to create a log file in Magento 2.4.3?

Add the folllwing code in your phtml file.How to create log file in magneto 2.4.3?

How to create log file in magneto 2.4.3?expoundsofttechsolution Install node js on Go Daddy Shared hosting.

$writer = new \Zend_Log_Writer_Stream(BP . '/var/log/custom.log'); //i.e your file will be created with the name custom.log in var/log/
$logger = new \Zend_Log();
$logger->addWriter($writer);
$logger->info('text message'); // 'text message' i.e the detail you want to print.