PHP code example of devgroup / yii2-graylog-target

1. Go to this page and download the library: Download devgroup/yii2-graylog-target 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/ */

    

devgroup / yii2-graylog-target example snippets


'components' => [
  'log' => [
    'grayii' => [
      'transport' => [
        'class' => \Gelf\Transport\HttpTransport::class,
        'host' => 'http://graylog2-server.com',
        'port' => 12201,
      ],
      'appName' => 'app name',
    ]
  ]
]

  Yii::info([
    'short' => 'Short message or title',  // l message of log. For example, may be a stack trace as string or other detalized message
    '_field1' => 'value1',                // optional. additional field starts with '_' symbol
    '_field2' => 'value2',                // optional. additional field starts with '_' symbol
  ]);
  

  try {
    ... running code with harmful bugs...
  } catch (\Throwable $t) {
    Yii::warning($t);
  }
  

  Yii::trace('The short message example'); // or equivalent usage is Yii::trace(['The short message example']);