PHP code example of everon / logger-gelf

1. Go to this page and download the library: Download everon/logger-gelf library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

everon / logger-gelf example snippets


    'pluginClass' => \Everon\LoggerGelf\Plugin\GelfHttp\GelfHttpLoggerPlugin::class,
    'pluginFactoryClass' => NULL,
    'logLevel' => \Monolog\Level::Debug,
    'shouldBubble' => true,
    'ignoreTransportErrors' => true,
    'host' => '127.0.0.1',
    'port' => 12202,
    'path' => '/gelf',
    'sslOptions' => NULL,
    

    'pluginClass' => \Everon\LoggerGelf\Plugin\GelfTcp\GelfTcpLoggerPlugin::class,
    'pluginFactoryClass' => NULL,
    'logLevel' => \Monolog\Level::Debug,
    'shouldBubble' => true,
    'ignoreTransportErrors' => true,
    'host' => '127.0.0.1',
    'port' => 12201,
    'sslOptions' => NULL,
    

    'pluginClass' => \Everon\LoggerGelf\Plugin\GelfUdp\GelfUdpLoggerPlugin::class,
    'pluginFactoryClass' => NULL,
    'logLevel' => \Monolog\Level::Debug,
    'shouldBubble' => true,
    'ignoreTransportErrors' => true,
    'host' => '127.0.0.1',
    'port' => 12201,
    'chunkSize' => \Gelf\Transport\UdpTransport::CHUNK_SIZE_WAN,
    

    'verifyPeer' => true,
    'allowSelfSigned' => false,
    'caFile' => NULL,
    'ciphers' => NULL,
    'useSsl' => false,
    

    use Everon\Shared\Logger\Configurator\Plugin\LoggerConfigurator;
    use Everon\Logger\EveronLoggerFacade;
    use Everon\Shared\LoggerGelf\Configurator\Plugin\GelfHttpLoggerPluginConfigurator;
    use Everon\Shared\LoggerGelf\Configurator\Plugin\GelfTcpLoggerPluginConfigurator;
    use Everon\Shared\LoggerGelf\Configurator\Plugin\GelfUdpLoggerPluginConfigurator;
    use Monolog\Level;
  
    $gelfHttpPluginConfigurator = (new GelfHttpLoggerPluginConfigurator)
        ->setLogLevel(Level::Debug)
        ->setHost('graylog.host.http');
  
    $gelfTcpPluginConfigurator = (new GelfTcpLoggerPluginConfigurator)
        ->setLogLevel(Level::Warning)
        ->setHost('graylog.host.tcp');
  
    $gelfUdpPluginConfigurator = (new GelfUdpLoggerPluginConfigurator)
        ->setLogLevel(Level::Info)
        ->setHost('graylog.host.udp');
    
    $configurator = (new LoggerConfigurator)
        ->addPluginConfigurator($gelfHttpPluginConfigurator)
        ->addPluginConfigurator($gelfTcpPluginConfigurator)
        ->addPluginConfigurator($gelfUdpPluginConfigurator);
    
    $logger = (new EveronLoggerFacade())->buildLogger($configurator);
    
    $logger->info('lorem ipsum');