Magento registers array contents

Mage :: log works fine for me, except when it comes to printing information about an array.

For example, if I have an array of $ result, and do the following:

Mage :: log ('[CartController: getDeliverLeadTime (country):'. $ Result. ')');

In my system.log file, I just get: [CartController: getDeliverLeadTime ~ (country): Array )

* I want it to print the actual structure and contents of the array, just like regular print_r did. *

If I do a var_dump of the array, I get nothing, i.e. [CartController: getDeliverLeadTime ~ (country) :).

If I do print_r, I get: [CartController: getDeliverLeadTime ~ (country): 1)

This is a blocker for me, since I cannot debug what I need - if someone can shed some light on how to get Magento to actually print the contents of the arrays in the logs, it would be very appreciated.

I read on alanstorm.com that this should happen by default, but this is not for me.

Thanks Paul

+5
source share
3 answers

You should return print_r as a string, so you print_r($result, true)should do the trick.

+14
source

Try

$array = array('ID' => 1, 'NAME' => 'Amaresh', 'EMAIL' => 'example@gmail.com');

Mage::log($array);

Output

2015-09-18T06:44:24+00:00 DEBUG (7): Array
(
    [ID] => 1
    [NAME] => Amaresh
    [EMAIL] => example@gmail.com
)
+1
source

Check out the code below the code,

$collection = Mage::getModel('catalog/product')->getCollection()
Mage::log("Query product: ".print_r($collection->getData(), true),null,'test.log');

check file test.login folder var/log.

0
source

All Articles