This extension can be used in Unix and Windows systems in order to route Yii logs through syslog/Windows Event Log.
Specially in Unix systems it may be useful if you want to route log messages in external log storage systems through syslog.
I am sure there are bugs or awful coding, but it was done in a short timeframe and you may consider this as a PoC.
Disclaimer: Don't use it in production or heavy loaded systems, there's no warranty that this piece of code won't explode your servers.
P.S: Windows Event support lacks of priorities, in case anyone has any idea, don't hesitate to share it in the forum discussion. UPDATE 9/9: The above bug is now fixed, thanks to Magomed :)
protected/extensionsIn config/main.php:
'log'=>array( 'class'=>'CLogRouter', 'routes'=>array( array( 'class'=>'ext.ESysLogRoute',//'CFileLogRoute', 'levels'=>'trace, info, error, warning', 'categories'=>'system.*', ), ), ),
You can change application log name and logging facility using the following params in config/main.php:
'params'=>array( 'logName' => 'Yii-Forum', 'logFacility' => LOG_LOCAL0, ),
The logFacility is not a string but an integer, refer to: http://us2.php.net/manual/en/function.openlog.php for details.
If you omit to define these application parameters it defaults to the following:
'logName' => 'YiiApp' 'logFacility' => LOG_USER
Last, the mapping i've done between Yii and Unix log levels is the following:
Yii - Unix ---------------------- trace - LOG_DEBUG info - LOG_INFO profile - LOG_NOTICE warning - LOG_WARNING error - LOG_ERR
Total 3 comments
I had problems getting the extention ESysLogRoute to work on yii-1.1.4.r2429.
What I did to get it working was firstly:
move protected/extentions/ESysLogRoute.php to protected/extenstions/syslogroute/ESysLogRoute.php
then change the configuration in main.php to:
array( 'class'=>'ext.syslogroute.ESysLogRoute', 'levels'=>'trace, info, error, warning', 'categories'=>'system.*', ),
Otherwise works like a charm and should be put into yii base.
Thanks, Atom
Thanks for the review MetaYii :)
Actually the remote logging process is handled by syslog itself. You can prefix a remote host with "@" sign so that syslog can start sending logs to it. There you could have a syslog-ng to parse and store log messages from multiple systems.
Therefore this extension is only useful to send log messages directly to syslog, the rest of the process is already handled by well-known tools/daemons.
Thanks again.
The code looks nice. Maybe faster disks/filesystem or logging to a remote server could help in high load situations?
Leave a comment
Please login to leave your comment.