1

I am creating log file for check either block of code is executing or not.

I am using following code for create log file

Mage::log('Inside block',null,"filename.log",true);

Its working perfectly and creating log file inside var/log/ folder.

Now I have doubt about I can delete that log file using any code.

I need to delete the log file programmatically,can I ?

Note : I want to delete only file not folder.

1

You can also try this:

$path = Mage::getBaseDir('var') . DS . 'log' . DS . 'filename.log';
$io = new Varien_Io_File();
$io->rm($path);
2

This should be possible via PHP's unlink function.

Example:

unlink(Mage::getBaseDir('var') . DS . "log" . DS . "filename.log");
  • Its working,but I asked any possiblity in magento way. 'sv3n' gave solution in magento way. I upvoted to your answer for your quick response.Thanks @Ricky Odin Matthews – Nagaraj Juro Mar 22 '18 at 6:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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