Get support for cebe/yii2-loki-log-target

If you're new to LTH, please see our FAQ for more information on what it is we do.

Support Options

Unfortunately, there are currently no active helpers for this repository on the platform. Until they become available, we reccomend the following actions:

View Open Issues

Take a look to see if anyone else has experienced the same issue as you and if they managed to solve it.

Open an Issue

Make sure to read any relevant guidelines for opening issues on this repo before posting a new issue.

Sponsor directly

Check out the page and see if there are any options to sponsor this project or it's developers directly.

cebe/yii2-loki-log-target

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:

// ...
'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 https://www.yiiframework.com/doc/guide/2.0/en/runtime-logging#log-targets.

Our Mission

We want to make open source more sustainable. The entire platform was born from this and everything we do is in aid of this.

Interesting Articles

Thank you for checking out LiveTechHelper |
2025 © lth-dev incorporated

p-e622a1a2