By default logs are only processed at the end of a request. FlushableLogRouter will process the logs as soon as they are flushed. Additionally it will take care of emptying the logs of each route.
Requirements ¶
Tested with Yii 1.1.6, but should also work with older versions.
Usage ¶
Save the class file to your components folder and configure your application's log component to use this class. The example below will process logs every 10 entries.
'log' => array(
'class' => 'FlushableLogRouter',
'autoFlush' => 10,
'routes' => array(...)
)
Note ¶
This component changes the $autoFlush property of CLogger.
User Contributed Notes 2
CLogRoute and memory allocation problems
This extension solves the memory allocation problems when using Yii::log thousand times in one request.
And also solves this "issue":
http://code.google.com/p/yii/issues/detail?id=1832
Thanks, very useful...
Logging twice
I have to log inside a loop about 2000 times.
So I decided to install the FlushableLogRouter flushing every 10 step. But then, every message is logged twice.
What can be the reason for this issue?
Leave a comment
If you have any questions, please ask in the forum instead.
Join the conversation to share a note.