Roman
Roman

Reputation: 15

Symfony 2 logger

Please help me with my problem. I am new with symfony 2 and i can't resolve my problem alone. I wan't to see my variable value in symfony 2 console and i read that it can be resolved with logger but when i use logger i see the type of my variable but i wan't to see a value of my variable. Have can i see it ???

public function helloAction($name)
{   
    $a = array('b' => 'ffsddsfs');
    $logger = $this->get('logger')->info($a);
    return array('name' => $name, 'a' => $a);
}

result.

INFO - Array

Upvotes: 1

Views: 2103

Answers (2)

acrobat
acrobat

Reputation: 2259

Please try it with this

$logger = $this->get('logger')->info(var_export($a, true));

This makes a string from your array and then the logger should be able to print the variable!

Upvotes: 2

NHG
NHG

Reputation: 5877

Your logger expected string (see docs) and you gave array, so php by default converted array type to string Array. You should use function for making string from your array, ex: print_r(). So you shold try this one:

$logger = $this->get('logger')->info(print_r($a));

Upvotes: 1

Related Questions