23/07
2015
Hello Graylog2 Bundle
Connecting logging through Graylog2 to projects on Symfony2 and the following Library: * Graylog2 gelf-php, (*4)
composer.json, (*5)
php composer.phar require hgtan/graylog-bundle:dev-master
Then register the bundle with your kernel:, (*6)
<?php // in AppKernel::registerBundles() $bundles = array( // ... new Hgtan\Bundle\HelloGraylogBundle\HgtanHelloGraylogBundle(), // ... );
# app/config/parameters.yml parameters: graylog_host: 172.16.4.105 graylog_port: 12201 # app/config/config.yml monolog: handlers: gelf: type: service id: monolog.gelf_handler level: debug
$ php app/console server:run http://127.0.0.1:8000/hello/graylog
Example:, (*7)
$logger = new Logger('Graylog2'); $gelfHandler = $this->get('monolog.gelf_handler'); $logger->pushHandler($gelfHandler); $logger->warning('Test warning message'); $logger->error('Test error message'); $logger->info('Test info message'); $logger->debug('Test debug message'); http://172.16.4.105:9000/