suver/yii2-logger
Composer 安装命令:
composer require suver/yii2-logger
包简介
log target for Yii2
README 文档
README
Credits
Benjamin Zikarsky https://github.com/bzikarsky/gelf-php
Installation
The preferred way to install this extension is through composer.
Either run
php composer.phar require "suver/yii2-logger" "*"
or add
"suver/yii2-logger" : "*"
to the require section of your application's composer.json file.
Usage
Add Graylog target to your log component config:
<?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', ], ]);
统计信息
- 总下载量: 532
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 2
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: BSD
- 更新时间: 2017-03-16