How we can print array variable in log file of Magento 2?
Suppose your array is
$a = array ('a' => 'apple', 'b' => 'banana', 'c' => array ('x', 'y', 'z'));
then you have to write below code to write proper array format in your log file
$this->_logger->log(100,print_r($a,true));
It will print in you log file
[2015-11-09 06:58:27] main.DEBUG: Array
(
[a] => apple
[b] => banana
[c] => Array
(
[0] => x
[1] => y
[2] => z
)
)
{"is_exception":false} []
See declaration of log method
public function \Psr\Log\LoggerInterface::log($level, $message, array $context = array());
So, you need code like
$this->_logger->log(100, json_encode($options));
This method works well for me.
$this->logger->info(print_r($myArray, true));
Then check your system.log
file.