This Symfony bundle enables logging to fluentd via monolog.
Fluentd is an open source data collector, it decouples data sources from backend systems by providing a unified logging layer in between.
composer require musement/monolog-fluentd-bundle
<?php
// AppKernel.php
use Symfony\Component\HttpKernel\Kernel;
use Symfony\Component\Config\Loader\LoaderInterface;
class AppKernel extends Kernel
{
public function registerBundles()
{
$bundles = array(
...
new Musement\MonologFluentdBundle\MusementMonologFluentdBundle(),
);
...
}
}
You can avoid loading the bundle (i.e. include it only in staging/prod environment) by means of something such as the following:
$bundles = array(
...
);
if (in_array($this->getEnvironment(), array('production', 'staging'))) {
$bundles[] = new Musement\MonologFluentdBundle\MusementMonologFluentdBundle();
}
These are the default parameters:
musement_monolog_fluentd:
host: localhost
port: 24224
options: []
level: debug
tag_fmt: '{{channel}}.{{level_name}}'
exceptions: true
You can modify them in config.yml or parameters.yml
You may load the handler as a service
monolog:
handlers:
musement_monolog_fluentd:
type: service
id: musement_monolog_fluentd.fluentd_handler
phpunit -c phpunit.xml.dist
© Musement S.p.A.