silinternational/yii2-jsonsyslog
最新稳定版本:1.0.1
Composer 安装命令:
composer require silinternational/yii2-jsonsyslog
包简介
Yii2 log target for sending data to Syslog as a JSON encoded string
README 文档
README
Yii2 log target for sending data to Syslog as a JSON encoded string, useful services such as Logentries.
Tips
Only send the JSON content
Make sure that the template you define for Logentries in your rsyslog.conf file
does not add other content before the %msg% data (aside from your
Logentries key). For example, do something like this...
$template Logentries,"LOGENTRIESKEY %msg%\n"
... NOT like this...
$template Logentries,"LOGENTRIESKEY %HOSTNAME% %syslogtag%%msg%\n"
Have the log prefix (if used) return JSON
Example (to be placed into your Yii2 config file's
['components']['log']['targets'] array):
[
'class' => 'sil\log\JsonSyslogTarget',
'levels' => ['error', 'warning'],
'except' => [
'yii\web\HttpException:401',
'yii\web\HttpException:404',
],
'logVars' => [], // Disable logging of _SERVER, _POST, etc.
'prefix' => function($message) use ($APP_ENV) {
$prefixData = array(
'env' => $APP_ENV,
);
if (! \Yii::$app->user->isGuest) {
$prefixData['user'] = \Yii::$app->user->identity->email;
}
return \yii\helpers\Json::encode($prefixData);
},
],
License
This is released under the MIT license (see LICENSE file).
统计信息
- 总下载量: 5.05k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 2
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-08-19