https://github.com/cebe/yii2-loki-log-target
Grafana Loki Log Target for Yii2
https://github.com/cebe/yii2-loki-log-target
Last synced: about 1 year ago
JSON representation
Grafana Loki Log Target for Yii2
- Host: GitHub
- URL: https://github.com/cebe/yii2-loki-log-target
- Owner: cebe
- License: mit
- Created: 2023-05-12T10:56:31.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2024-06-06T14:44:16.000Z (about 2 years ago)
- Last Synced: 2025-04-17T07:17:07.927Z (about 1 year ago)
- Language: PHP
- Size: 21.5 KB
- Stars: 5
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# yii2-loki-log-target
Grafana Loki Log Target for Yii2.
## Requirements
- PHP 7.1 or higher (works with PHP 8)
- Yii 2
## Install
composer require cebe/yii2-loki-log-target
## Usage
Add the log target to your application config:
```php
// ...
'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',
],
],
],
],
],
]
```
See also .