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

Issue Type: Bug Created: 2012-08-07T01:05:21.000+0000 Last Updated: 2012-08-28T14:56:03.000+0000 Status: Closed Fix version(s): Reporter: Thomas R. (thomas_r) Assignee: Ralph Schindler (ralph) Tags: - Zend\Log

  • formatter
  • log
  • xml

Related issues: Attachments:


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.


Posted by Koen Pieters (koen) on 2012-08-07T14:22:59.000+0000

Send pull request:

Posted by Koen Pieters (koen) on 2012-08-09T09:55:59.000+0000

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:

<pre class="highlight">
2012-08-09T9:42:33+02:006INFOinformational messageArray

When I tested with:

<pre class="highlight">
$logger->info('informational message', array('extra_key' => 'extra value'));

The output was the following:

<pre class="highlight">
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…

Posted by Benoît Durand (intiilapa) on 2012-08-24T19:38:51.000+0000

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

Posted by Maks 3w (maks3w) on 2012-08-24T23:58:30.000+0000

patch merged

Posted by Koen Pieters (koen) on 2012-08-28T14:56:03.000+0000

issue closed.

Thanks Ralph for your unit test.

Have you found an issue?

See the Overview section for more details.


© 2006-2018 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.