PHP code example of dennisvanbeersel / symfony-logger-client
1. Go to this page and download the library: Download dennisvanbeersel/symfony-logger-client 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/ */
dennisvanbeersel / symfony-logger-client example snippets
return [
// ...
ApplicationLogger\Bundle\ApplicationLoggerBundle::class => ['all' => true],
];
use Psr\Log\LoggerInterface;
final class CheckoutService
{
public function __construct(private readonly LoggerInterface $logger)
{
}
public function process(Order $order): void
{
try {
// ... domain logic ...
} catch (\Throwable $e) {
// Routed to error tracking (carries a Throwable in context).
$this->logger->error('Checkout failed', [
'exception' => $e,
'order_id' => $order->getId(),
]);
throw $e;
}
}
}
$this->logger->warning('Payment gateway latency elevated', [
'gateway' => 'acme-pay',
'latency_ms' => 812,
]);