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.

2 Answers 2


You can also try this:

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

This should be possible via PHP's unlink function.


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 Mar 22, 2018 at 6:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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