ZF2-18: Extending Zend_Log using namespaces

Issue Type: Bug Created: 2011-06-06T20:56:02.000+0000 Last Updated: 2011-12-22T19:38:20.000+0000 Status: Resolved Fix version(s): Reporter: Eric Andre (eandre) Assignee: Evan Coury ( Tags: - Zend\Log

  • zf-crteam-padraic
  • zf-crteam-priority

Related issues: - ZF-11450



In Zend_Log::factory in line 139 (ZF 1.11) an instance of Zend_Log is created with $log = new self;.

Let me give a use-case to explain:

somewhere at bootstrapping:

<pre class="highlight">
$autoloader = Zend_Loader_Autloader::getInstance();

extending Zend_Log:

<pre class="highlight">
My_Log extends Zend_Log {

 public function log($message, $priority, $extras = null) {
     // do something else
     parent::log($message, $priority, $extras);


Also at bootstrapping:

<pre class="highlight">
$logger = My_Log::factory(...);

So the My_Log::log method never will be called -> $log = new self;

First option is to override the Zend_Log::factory and replace $log = new self to $log = new My_Log, but this is urgh. Better code this:

<pre class="highlight">
$log = new static;

With this pice of code it is possible to get, due to late static binding, a instance of My_Log, and not Zend_Log...

What do u think?

Tested with ZF 1.8 - 1.11 - works fine (of course > PHP5.3)



Posted by Benoît Durand (intiilapa) on 2011-06-06T21:06:04.000+0000

@Eric ZF1 must be compatible with PHP 5.2.

Posted by Matthew Weier O'Phinney (matthew) on 2011-06-06T21:15:21.000+0000

I'm going to move this issue to the ZF2 issue tracker, as LSB is only available in PHP >= 5.3, and ZF1's minimum version is 5.2.6. There may be other ways to potentially support this in 5.2, but the proper way is using LSB.

Posted by Benoît Durand (intiilapa) on 2011-06-07T04:55:52.000+0000

All factory methods of logger, writers, filtesr, and formatters are being refactored within ZF2.

Posted by Eric Andre (eandre) on 2011-06-07T08:55:23.000+0000

Okay, i dont respect the compatibility. So thanks for regarding this issue.

Posted by Benoît Durand (intiilapa) on 2011-09-03T08:26:39.000+0000

Once the common API (puggable, configurator, etc.) will have been decided for the core components of ZF2, Logger will adopt it. Being able to extend any core component is a requirement for this solution.

It is also possible to consider including events in order to customize the logging.

Posted by Evan Coury ( on 2011-12-21T22:14:42.000+0000

I see no reason for us to wait until after we refactor for the new configuration style to make this change. LSB is the correct way to handle a situation like this, and it's a simple enough change. I went ahead and issued a PR for this:

Posted by Rob Allen (rob) on 2011-12-22T19:38:20.000+0000

Merged to master

Have you found an issue?

See the Overview section for more details.


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

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