PHP code example of onramplab / laravel-log-enhancement

1. Go to this page and download the library: Download onramplab/laravel-log-enhancement 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/ */

    

onramplab / laravel-log-enhancement example snippets


use Monolog\Formatter\LogglyFormatter;
use Onramplab\LaravelLogEnhancement\Handlers\LogglyHandler;

return [
  //...


  'channels' => [
    //...

    'loggly' => [
        'driver' => 'monolog',
        'level' => 'info',
        'handler' => LogglyHandler::class,
        'handler_with' => [
            'token' => env('LOGGLY_TOKEN'),
            'tags' => env('LOGGLY_TAGS'),
        ],
        'formatter' => LogglyFormatter::class,
    ],
  ]
];


use Monolog\Formatter\JsonFormatter;
use Onramplab\LaravelLogEnhancement\Handlers\DatadogHandler;

return [
  //...

  'channels' => [
    //...

    'datadog' => [
      'driver' => 'monolog',
      'level' => 'info',
      'handler' => DatadogHandler::class,
      'handler_with' => [
          'key' => env('DD_LOG_API_KEY'),
          'region' => env('DD_LOG_REGION', 'us5'),
          'attributes' => [
              'hostname' => gethostname(),
              'source' => env('DD_LOG_SOURCE', 'laravel'),
              'service' => env('DD_LOG_SERVICE'),
              'tags' => env('DD_LOG_TAG'),
          ],
      ],
      'formatter' => JsonFormatter::class,
    ],
  ]
];

bash
curl -LO https://github.com/DataDog/dd-trace-php/releases/latest/download/datadog-setup.php
sudo php datadog-setup.php --php-bin=all