user269867
user269867

Reputation: 3972

Zend_log create two log files

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,

Upvotes: 1

Views: 2587

Answers (1)

Michael
Michael

Reputation: 1267

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.

Upvotes: 0

Related Questions