1

I am writing my own Zend_log and having difficulty in following. I have to generate module specific logs which I am able to but with this I am also creating global one application.log ! which I do not want ..

In my application.ini

resources.log.stream.writerName = "Stream"
resources.log.stream.writerParams.stream = APPLICATION_PATH "/../logs/application.log"

I have bootstrap code

if ($this->hasPluginResource("log"))
        {
            $r = $this->getPluginResource("log");
            $log = $r->getLog();
            Zend_Registry::set('log',$log);
        }

In my Logger class I am trying to over write _stream so that when Log is written It always write to single file .code as follow

$writerArr=array('stream'=>$logfile,'mode'=>'a');
$writer = Zend_Log_Writer_Stream::factory($writerArr);

But as I have provided the application.log in config file it is always creating application.log !...

I want to overwrite those stream but not able to understand how? Any method which ensure that there is only one writer/stream to write in ??...

Or else I am advised to remove application.ini and bootstrap code but then I won't be able to record ErrorController.php error...

I was hoping solution that "application.log" for errors thrown by ErrorController.php and for App error I wanted my Logger class to log the error...but I am not able to ensure single stream at a time...

Any clue?

Regards,

user269867
  • 3,266
  • 9
  • 45
  • 65
  • i believe this line `resources.log.stream.writerParams.stream = APPLICATION_PATH "/../logs/application.log"` is not helping – Michael Sep 07 '12 at 07:03
  • If i remove that line I get Error - Fatal error: Uncaught exception 'Zend_Log_Exception' with message '"" cannot be opened with mode "a"' in C:\wamp\www\demo\library\Zend\Log\Writer\Stream.php on line 81 – user269867 Sep 07 '12 at 07:09

1 Answers1

0

Try to delete whole application.ini code and make zend_log init in bootstrap itself:

$writer = new Zend_Log_Writer_Stream('[/your/log/file/path]', '[file_open_mode]');
$logger = new Zend_Log($writer);

Best if you initialize writer when you know in which place will you be writing and after that initialize logger itself.

Michael
  • 1,067
  • 8
  • 13
  • I removed application.ini and bootstrap code and kept writing in my Logger function which is the only option I have. In any case, I can handle application.log for logging ErrorController.php messages globally in single file where as handling module level logging with my Logger class... – user269867 Sep 07 '12 at 12:33