ZF2-453: Logger xml formatter not accepting arrays (from extra params)

Description

taken from rtfd: $writer = new Zend\Log\Writer\Stream('php://output'); $formatter = new Zend\Log\Formatter\Xml(); $writer->setFormatter($formatter);

$logger = new Zend_Log(); $logger->addWriter($writer); $logger->info('informational message');

This causes an array to string conversion notice error in the xml file line 157: $elt->appendChild(new DOMElement($key, (string)$value));

The extra params are passed as an array. I think this code comes directly from the config xml writer, as that suffers from exactly the same problem.

Comments

Hi Thomas,

I've made the pull request cause if I used your code example.

I didn't get the notice, but got this as a result:


2012-08-09T9:42:33+02:006INFOinformational messageArray

When I tested with:


$logger->info('informational message', array('extra_key' => 'extra value'));

The output was the following:


2012-08-09T9:42:33+02:006INFOinformational message

I had a look at the code, and the extra options are, as far as I could see, implemented for the errorHandler and the ExceptionHandler, but not for XML.

Cause the empty didn't seem right, I did a pull request for not showing this in the xml output.

Did you test it on the latest ZF2 from git? Do you still get the notice?

PS. I've also did a pull request to update the documentation for the right example ( $logger = new Zend\Log\Logger(); ) on http://packages.zendframework.com/docs/latest/…

The PR is merged on master. Can we close this issue?

patch merged

issue closed.

Thanks Ralph for your unit test.