I want to write a custom log file which contains order and timestamp in the log file.

I tried Mage::log() but stops the file running afterwards and footer disappears.

Can anyone guide me in that?

Thank you


Are you trying to combine the timestamp and order in one single log call. This would cause an error. Mage::log() actually prepends the timestamp so all you would need to do is:

Mage::log($order->getData(), null, 'custom.log', true);

$order in the case above is an instance of the order class.

If doesn't work then its likely to be another error. I would turn on error logging and check your system.log and exception.log files.

You could also turn on error_reporting and developer mode in the index.php file and see what error is been thrown.

  • Can I add $_SERVER['HTTP_USER_AGENT'] to the log file? – Bhargav Mehta Mar 13 '16 at 16:33
  • You can do. You couldn't combine that with the array in 1 call to Mage::log though. They would have to be 2 separate calls. – Colin Murphy Mar 13 '16 at 16:42
  • I am adding Mage::log($order->getData(), null, 'custom.log', true); Mage::log($_SERVER['HTTP_USER_AGENT'], null, 'custom.log', true); will this cause the script to die? Or will it continue everything to execute? – Bhargav Mehta Mar 13 '16 at 16:46
  • Colin I tried the above code and its breaking the success.phtml page as footer is not coming – Bhargav Mehta Mar 13 '16 at 17:01
  • Mage::log() will allow the script to execute. Can you post up the full template code here and also turn on error reporting and post up what error you are getting please. Mage::log() shouldn't break the code. – Colin Murphy Mar 13 '16 at 17:06

You are trying to write the entire order object which will make the script to die. Just write only the data you need. For example


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.