Monolog JsonFormatter没有格式化我的代码?

I've read a lots of questions here and read some documentation. But Still don't understand how to format a JSON value with monolog.

Here my code that is not working:

php $formatter = new JsonFormatter(); $log->addInfo($formatter->format(['foo' => 'bar']));

The output is always in one line instead of in a formatted way.

bash [2016-03-02 07:45:57] parameters.INFO: {"foo":"bar"} [] []

The JsonFormatter is meant to be used for formatting the output.

$log = new \Monolog\Logger( 'my_log' );
$stream_handler = new \Monolog\Handler\StreamHandler( 'my_log_file.log' );
$stream_handler->setFormatter( new \Monolog\Formatter\JsonFormatter() );
$log->pushHandler( $stream_handler );

$log->addError( 'foo' );

Without the JsonFormatter you get the normal output:

[2016-04-04 16:37:55] my_log.ERROR: foo [] [] 

With the JsonFormatter you get JSON output:

{"message":"foo","context":[],"level":400,"level_name":"ERROR","channel":"my_log","datetime":{"date":"2016-04-04 16:38:14.102258","timezone_type":3,"timezone":"UTC"},"extra":[]}