vbelozyorov/monolog-gearman-handler
Composer 安装命令:
composer require vbelozyorov/monolog-gearman-handler
包简介
Gearman Handler for Monolog logging library
README 文档
README
Monolog handler for sending logs to Gearman. May be usefull for async recording those logs on another machine.
Requirements
As you see from package name, this one is useless without Gearman PHP extension . Since Composer cannot install it, you need to do it yourself.
Install
composer require vbelozyorov/monolog-gearman-handler
This will install this package itself and, Monolog, if not yet installed.
Configure
Because handler constructor requires Gearman client, which in turn requires host and port of Gearman server, you need to be able to provide all this when logger will initialized.
Here is example for YAML config for Symfony2:
services: gearman.client: class: GearmanClient calls: - [addServer, [%logs.gearman_host%, %logs.gearman_port%]] monolog.gearman_handler: class: Monolog\Handler\GearmanHandler arguments: - '@gearman.client' calls: - [setPrefix, ['project_alias']] monolog: channels: [gearman] handlers: gearman: type: service id: monolog.gearman_handler level: debug channels: [gearman] main: channels: ['!gearman']
In this example separate Monolog channell named gearman is registered. And handler main using in Symfony app by default
excludes from this new channel. This way event logs like kernel.debug won't be published there.
How you get Gearman logger with this config:
$logger = $this->getContainer()->get('monolog.logger.gearman');
统计信息
- 总下载量: 3
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2017-03-31