1. Go to this page and download the library: Download changole/otel-logging 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/ */
changole / otel-logging example snippets
'channels' => [
// ...
'otel' => [
'driver' => 'monolog',
'handler' => Changole\OtelLogging\Otel\OtelLogHandler::class,
],
// Or use it in a stack
'stack' => [
'driver' => 'stack',
'channels' => ['single', 'otel'],
'ignore_exceptions' => false,
],
],
// Using the dedicated channel
Log::channel('otel')->info('This is a test message', ['user_id' => 123]);
// Or when using the stack (if you added 'otel' to your stack channels)
Log::info('This message will go to both file and OpenTelemetry', [
'user_id' => 123,
]);