hgtan/graylog-bundle

Hello Graylog2 Bundle

dev-master / 1.0.1.x-dev 2015-07-23 08:22 UTC

This package is not auto-updated.

Last update: 2024-11-23 18:43:29 UTC


README

Latest Stable Version Total Downloads Latest Unstable Version License

Build Status Coverage Status Quality Score HHVM Status

SensioLabsInsight

Connecting logging through Graylog2 to projects on Symfony2 and the following Library:

Installation

Step 1: Using Composer

composer.json

    php composer.phar require hgtan/graylog-bundle:dev-master

Step 2 : Register the bundle

Then register the bundle with your kernel:

    <?php

    // in AppKernel::registerBundles()
    $bundles = array(
        // ...
        new Hgtan\Bundle\HelloGraylogBundle\HgtanHelloGraylogBundle(),
        // ...
    );

Step 3 : Configure the bundle

    # 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    

Step 4 : Test

    $ php app/console server:run
    
    http://127.0.0.1:8000/hello/graylog
    

Example:

    $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/