PHP code example of silinternational / yii2-json-log-targets

1. Go to this page and download the library: Download silinternational/yii2-json-log-targets library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

silinternational / yii2-json-log-targets example snippets


    'log' => [
        'targets' => [
            [
                'class' => 'Sil\JsonLog\target\EmailServiceTarget',
                'levels' => ['error'],
                'except' => [
                    'Sil\EmailService\Client\EmailServiceClientException',
                ],
                'logVars' => [], // Disable logging of _SERVER, _POST, etc.
                'message' => [
                    'to' => '[email protected]',
                    'cc' => '[email protected]',         // optional
                    'bcc' => '[email protected]',     // optional
                    'subject' => 'Alert from application',
                ],
                'baseUrl' => 'https://emailservice.mydomain.com',
                'accessToken' => 'asdf1234',
                'assertValidIp' => true,
                'validIpRanges' => ['10.0.10.0/24','127.0.0.1'],
                'enabled' => true,
            ],
        ],
    ],

    'log' => [
        'targets' => [
            [
                'class' => 'Sil\JsonLog\target\JsonFileTarget',
                'levels' => ['error', 'warning'],
                'logVars' => [], // Disable logging of _SERVER, _POST, etc.
            ],
        ],
    ],

    'log' => [
        'targets' => [
            [
                'class' => 'Sil\JsonLog\target\JsonSyslogTarget',
                'levels' => ['error', 'warning'],
                'except' => [
                    'yii\web\HttpException:401',
                    'yii\web\HttpException:404',
                ],
                'logVars' => [], // Disable logging of _SERVER, _POST, etc.
            ],
        ],
    ],