Log Help

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
ziuccio
Forum Newbie
Posts: 11
Joined: Mon Jun 28, 2010 11:24 am

Log Help

Post by ziuccio »

Hi there,
I need your help.
I don`t undertand how to use the logger in my application with Zend Framework 1.10.5

I have built the project with zf tools following the tutorial

Now I would like to set a log system.

in the bootstrap.php I have added this function

Code: Select all

   protected function _initLogging()
    {
        $this->bootstrap('frontController');
        $logger = new Zend_Log();

        $writer = 'production' == $this->getEnvironment() ?
                        new Zend_Log_Writer_Stream(APPLICATION_PATH . '/../data/logs/app.log') :
                        new Zend_Log_Writer_Firebug();
        $logger->addWriter($writer);

                if ('production' == $this->getEnvironment()) {
                        $filter = new Zend_Log_Filter_Priority(Zend_Log::CRIT);
                        $logger->addFilter($filter);
                }

        $this->_logger = $logger;
        Zend_Registry::set('log', $logger);
    } ]
and in my IndexController.php

Code: Select all

public function indexAction()
    {
        $logger->debug('Test');
    }
When I run the application I have a blank page.
Deleting the

Code: Select all

 $logger->debug('Test'); 
the application goes normally.

I am wondering how can I log to the file app.log and if I have to set some variables in the application.ini...like...[text]resources.logging.something...[/text]

I really appreciate your help.

Ziuccio
Post Reply