cebe / yii2-loki-log-target
Grafana Loki 日志目标用于 Yii2
1.2.0
2024-06-06 14:43 UTC
Requires
- php: >=7.1.0
- yiisoft/yii2: ~2.0.0
- yiisoft/yii2-httpclient: ^2.0
README
Grafana Loki 日志目标用于 Yii2。
要求
- PHP 7.1 或更高版本(与 PHP 8 兼容)
- Yii 2
安装
composer require cebe/yii2-loki-log-target
用法
将日志目标添加到您的应用程序配置
// ... 'components' => [ // ... 'log' => [ // ... 'targets' => [ [ 'class' => \cebe\lokilogtarget\LokiLogTarget::class, //'enabled' => YII_ENV_PROD, 'lokiPushUrl' => 'https://loki.example.com/loki/api/v1/push', 'lokiAuthUser' => 'loki', // HTTP Basic Auth User 'lokiAuthPassword' => '...', // HTTP Basic Auth Password 'levels' => ['error', 'warning', 'info'], // optionally exclude categories 'except' => [ 'yii\db\Connection::open', 'yii\db\Command::execute', 'yii\httpclient\StreamTransport::send', ], // optionally re-map log level for certain categories 'levelMap' => [ // yii category 'yii\web\HttpException:404' => [ // yii level => loki level // set loki level to false, to drop messages with that category '*' => 'info', ], 'yii\web\HttpException:401' => [ // yii level => loki level // set loki level to false, to drop messages with that category '*' => 'warning', ], ], ], ], ], ]
请参阅此处。