Quick debugging tip
Posted on 03. Sep, 2008 by Fido in Development, Magento, Module
You can add items to magento’s system log and exception log in your code. This is very handy for pin-pointing coding errors / problems. Developing for Magento is often hard, especially since it’s not always possibly to have error reporting on (and even when it is on, its hard to find exactly what’s wrong!).
Here’s an example of it’s use:
1) Turn on your logging: Admin > Configuration > Developer > Log Settings > Enabled = Yes
2) Example code snippet where you might find this useful:
<?php $response = curl_exec($ch); //just an example of something - might use this in a custom payment or shipping module Mage::log($responseBody); ?>
3) Watch your var/log/system.log and var/log/exception.log for raw information from this.
You may run into file permission errors, so you might need to set your folder permissions appropriately




4 Comments
aledujke
07. Nov, 2008
I’m currently working with observers and this helped me a lot.
Thanks!
jimmy
21. Jul, 2009
thanks a lot
Stephan Miller
29. Aug, 2009
Thanks. I needed this. I knew how to turn it on. Just wasn’t sure where the info would be logged.
Jared Blalock
09. Dec, 2009
Thanks for the tip, this could come in handy!
Leave a reply