Tying all together.
The gelf.xml should be placed in the Directory Resources/config in one of your bundles (for example Acme\Bundle). Then adjust the extension file of this bundle (in our case it would be Acme\Bundle\DependencyInjection\AcmeExtensions).
<?php
namespace Acme\Bundle\DependencyInjection;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
use Symfony\Component\DependencyInjection\Loader;
class AcmeExtension extends Extension
{
/**
* {@inheritDoc}
*/
public function load(array $configs, ContainerBuilder $container)
{
// ...
$loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
$loader->load('gelf.xml');
// ...
}
}
Adjust the parameters to your needs (parameters.yml/parameters.ini):
parameters:
graylog.hostname: graylog.example.com
graylog.port: 29833 # only adjust it when you don't use the default port
# DEBUG
# monolog.handler.gelf.debug_level: 100
# INFO (default)
monolog.handler.gelf.debug_level: 200
# WARNING
# monolog.handler.gelf.debug_level: 300
# ERROR
# monolog.handler.gelf.debug_level: 400
# CRITICAL
# monolog.handler.gelf.debug_level: 500
# ALERT
# monolog.handler.gelf.debug_level: 550
Finally you can add the gelf handler in your config.yml:
# ...
monolog:
handlers:
gelf:
type: service
id: monolog.gelf_handler
# ...
Hello thanks for this.
How can I do the same config in drupal 8 only with yaml file.
Thanks