PHP code example of pedromazala / fluentd-logger

1. Go to this page and download the library: Download pedromazala/fluentd-logger 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/ */

    

pedromazala / fluentd-logger example snippets


Illuminate\Support\Facades\Log::info("hello world");

fluent_measure('widget.created', ['widgets' => 4], ['username' => 'leroy']);

$fluent_logger = new \Tokenly\FluentdLogger\FluentLogger($host, $port);

# set a tag prefix
$app_code = 'myapp';
$environment = 'production';
$tag = 'applog.'.$app_code.'.'.$environment;

# set up monolog
$monolog->pushHandler(new \Tokenly\FluentdLogger\FluentMonologHandler($fluent_logger, $tag));

# set up fluent event logger for measurements
$measurement_logger = new \Tokenly\FluentdLogger\FluentEventLogger($fluent_logger, 'measure.'.$app_code.'.'.$environment);


# use monolog
$monolog->info("hi world");

# use measurements
$measurement_logger->log('widget.created', ['widgets' => 4], ['username' => 'leroy']);