简体   繁体   中英

Logging requests of Zend Framework application

i need help with logging Zend Framewrok application ( version 1.11 ), every request..

I need to know time of beinning request and time of executing request. Each request i would like to save into database, but i'm not sure, where i would catch these informations.

Beggining of request i can probably catch in bootstrap.php via some _init method. But in which place should I cach information about end of execution request, if i need to be connected into database? In addition i'm using $this->_redirector->gotoSimpleAndExit() in my controllers and i need count with that case - no view is rendered and request is finished simply by exit() function.

I would like to write log information only once per request.

Thank's for help!

Registration of shut down function helped very well. http://php.net/manual/en/function.register-shutdown-function.php

I created custom logger (singleton pattern), that i'm calling in bootstrap.. since php 5.4 is available $_SERVER['REQUEST_TIME_FLOAT']. Logger register his method as shutdown function in constructor and also call it in his destructor. Multiple calling of shutdown function is prevented.

This solution is working even if exit() function is called.

For one of my projects, I'm putting the "end of execution" logging code in my layout script. It's supposed to be one of the "last" things to be executed.

I'm not using redirections for this project, though. So, I'm not sure how it should be extended to consider your "gotoSimpleAndExit()" case.

Hope that helps,

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM