adamaru/monolog-fluentd-bundle

此包已废弃,不再维护。未建议替代包。

定义 fluentd 处理器的 Symfony 扩展包,用于 Monolog

v0.7.0 2018-12-17 13:52 UTC

This package is auto-updated.

Last update: 2022-03-22 17:59:21 UTC


README

This bundle enables logging to the fluentd log concentrator from Symfony.
Fluentd is an open source datacollector and decouples your logging collection
and analysis tools from your project by sending all logs from deamons, apps
in front and backend to one single daemon and use filtering to selectively
forward to storage engine / analysis tools

fluentd 处理器,作为 Symfony 扩展包用于 Monolog

安装

内核

$bundles = array(
    //..
    new Seretalabs\MonologFluentdBundle\MonologFluentdBundle(),
);

自动加载

$loader->registerNamespaces(array(
    //..
    'Seretalabs' => __DIR__.'/../vendor/bundles',
));

配置

配置 Monolog

monolog:
    handlers:
        main:
            type:         fingers_crossed
            action_level: error
            handler:      fluentd
        fluentd:
            type: service
            id: monolog_fluentd.monolog_handler

配置 fluentd 的 Monolog

monolog_fluentd:
    # fluentd API host
    host: localhost

    # fluentd API port default 24224
    port: 24224

    # Level to be logged (defaults to DEBUG)
    level: DEBUG

    bubble: true

用法

<?php
use Monolog\Logger;

$logger->debug('example.monolog', array('foo' => 'bar'));
$logger->info('example.fluentd', array('fizz' => 'buzz'));

// Fluentd:
// 2013-10-11 01:00:00 +0900 dakatsuka.example.monolog: {"foo":"bar","level":"DEBUG"}
// 2013-10-11 01:00:00 +0900 dakatsuka.example.fluentd: {"fizz":"buzz","level":"INFO"}

致谢

This bundle uses [daktsuka](https://github.com/dakatsuka)'s fluentd handler for Monolog [https://github.com/dakatsuka/MonologFluentHandler]