2017 © Pedro Peláez
 

yii2-extension yii2-logger

log target for Yii2

image

suver/yii2-logger

log target for Yii2

  • Wednesday, April 26, 2017
  • by suver
  • Repository
  • 1 Watchers
  • 1 Stars
  • 345 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 5 Versions
  • 183 % Grown

The README.md

log target for Yii2

Credits

Benjamin Zikarsky https://github.com/bzikarsky/gelf-php, (*1)

Installation

The preferred way to install this extension is through composer., (*2)

Either run, (*3)

php composer.phar require "suver/yii2-logger" "*"

or add, (*4)

"suver/yii2-logger" : "*"

to the require section of your application's composer.json file., (*5)

Usage

Add Graylog target to your log component config:, (*6)

<?php
return [
    ...
    'components' => [
        'log' => [
            'traceLevel' => YII_DEBUG ? 3 : 0,
            'targets' => [
                'file' => [
                    'class' => 'yii\log\FileTarget',
                    'levels' => ['error', 'warning'],
                ],
                'graylog' => [
                    'class' => 'suver\logger\GraylogTarget',
                    'levels' => ['error', 'warning', 'info'],
                    'categories' => ['application'],
                    'logVars' => [], // This prevent yii2-debug from crashing ;)
                    'type' => 'udp', // tcp, udp, amqp
                    'transport' => [
                        'host' => 'graylog',
                        'port' => '12201',
                    ],
                    'facility' => 'facility-name',
                ],
            ],
        ],
    ],
    ...
];
<?php
// short_message will contain string representation of ['test1' => 123, 'test2' => 456],
// no full_message will be sent
Yii::info([
    'test1' => 123,
    'test2' => 456,
]);

// short_message will contain 'Test short message',
// two additional fields will be sent,
// full_message will contain all other stuff without 'short' and 'add':
// string representation of ['test1' => 123, 'test2' => 456]
Yii::info([
    'test1' => 123,
    'test2' => 456,
    'short' => 'Test short message',
    'add' => [
        'additional1' => 'abc',
        'additional2' => 'def',
    ],
]);

// short_message will contain 'Test short message',
// two additional fields will be sent,
// full_message will contain 'Test full message', all other stuff will be lost
Yii::info([
    'test1' => 123,
    'test2' => 456,
    'short' => 'Test short message',
    'full' => 'Test full message',
    'add' => [
        'additional1' => 'abc',
        'additional2' => 'def',
    ],
]);

The Versions

26/04 2017

dev-master

9999999-dev https://github.com/suver/yii2-logger

log target for Yii2

  Sources   Download

BSD 3-Clause

The Requires

 

log extension yii2 graylog2 graylog gelf log target

26/04 2017

1.0.3-stable

1.0.3.0 https://github.com/suver/yii2-logger

log target for Yii2

  Sources   Download

BSD 3-Clause

The Requires

 

log extension yii2 graylog2 graylog gelf log target

16/03 2017

1.0.2-stable

1.0.2.0 https://github.com/suver/yii2-logger

log target for Yii2

  Sources   Download

BSD 3-Clause

The Requires

 

log extension yii2 graylog2 graylog gelf log target

16/03 2017

1.0.0-stable

1.0.0.0 https://github.com/suver/yii2-logger

log target for Yii2

  Sources   Download

BSD 3-Clause

The Requires

 

log extension yii2 graylog2 graylog gelf log target

16/03 2017

1.0.1-stable

1.0.1.0 https://github.com/suver/yii2-logger

log target for Yii2

  Sources   Download

BSD 3-Clause

The Requires

 

log extension yii2 graylog2 graylog gelf log target