PHP code example of oat-sa / lib-correlation-ids-monolog
1. Go to this page and download the library: Download oat-sa/lib-correlation-ids-monolog 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/ */
oat-sa / lib-correlation-ids-monolog example snippets
declare(strict_types=1);
use OAT\Library\CorrelationIds\Registry\CorrelationIdsRegistry;
use OAT\Library\CorrelationIds\Registry\CorrelationIdsRegistryInterface;
use OAT\Library\CorrelationIdsMonolog\Processor\CorrelationIdsMonologProcessor;
use Monolog\Logger;
/** @var CorrelationIdsRegistryInterface $registry */
$registry = new CorrelationIdsRegistry(...);
$logger = new Logger('channel-name');
$logger->pushProcessor(new CorrelationIdsMonologProcessor($registry));
...
$logger->info('log message'); // this log entry context will be automatically populated with the correlation ids.