we-push-it / yii2-splunk-log-target
Yii 2 日志目标,可以通过curl将日志记录到Splunk Enterprise
1.0.1
2019-12-29 10:13 UTC
Requires
- yiisoft/yii2: ~2.0.0
This package is auto-updated.
Last update: 2024-08-30 01:21:14 UTC
README
允许您将日志发送到您的Splunk Enterprise。
安装
composer require "we-push-it/yii2-splunk-log-target"
使用
为了使用SplunkTarget
,您应该像以下那样配置您的log
应用程序组件
return [ // ... 'bootstrap' => ['log'], // ... 'components' => [ // ... 'log' => [ 'targets' => [ [ 'class' => wepushit\log\SplunkTarget::class, // It is optional parameter. The message levels that this target is interested in. // The parameter can be an array. 'levels' => ['error', 'warning'], ], // ... ], ], ], ];
您也可以组合您的日志目标
'log' => [ 'traceLevel' => YII_DEBUG ? 3 : 0, 'targets' => [ [ 'class' => yii\log\FileTarget::class, 'levels' => ['error', 'warning'], ], [ 'class' => wepushit\log\SplunkTarget::class, 'levels' => ['error', 'warning'] ], ], ],
另外,您应该调整您的params-config
return [ // ... 'splunk' => [ 'host' => isset($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : 'example server', 'token' => 'token from your Splunk HTTP Event Collector', 'url' => 'https://example.com:8088/services/collector/event', 'source' => 'example', 'sourcetype' => 'yii-errorhandler', ], ];
标准用法
Yii::info('Info message'); Yii::error('Error message');