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 :)
Resources ¶
Documentation ¶
Requirements ¶
- Yii 1.0 or above
Installation ¶
- Extract the release file under
protected/extensions
Usage ¶
In 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
Change Log ¶
September 9, 2009 ¶
- Third release bugfix: case statement missing breaks, priorities in windows systems now behave normally. (thanks to Magomed)
July 6, 2009 ¶
- Second release added initial support for windows platforms
June 25, 2009 ¶
- Initial release.
autoload problem on yii-1.1.4
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
Re: Looks nice
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.
Looks nice
The code looks nice. Maybe faster disks/filesystem or logging to a remote server could help in high load situations?
If you have any questions, please ask in the forum instead.
Signup or Login in order to comment.