github getsentry/sentry-php 4.15.0

latest release: 4.15.1
12 days ago

The Sentry SDK team is happy to announce the immediate availability of Sentry PHP SDK v4.15.0.

Features

  • Add Monolog Sentry Logs handler (#1867)

    This new handler allows you to capture Monolog logs as Sentry logs. To use it, configure your Monolog logger:

    use Monolog\Logger;
    use Sentry\Monolog\LogsHandler;
    use Sentry\Logs\LogLevel;
    
    // Initialize Sentry SDK first (make sure 'enable_logs' is set to true)
    \Sentry\init([
        'dsn' => '__YOUR_DSN__',
        'enable_logs' => true,
    ]);
    
    // Create a Monolog logger
    $logger = new Logger('my-app');
    
    // Add the Sentry logs handler
    // Optional: specify minimum log level (defaults to LogLevel::debug())
    $handler = new LogsHandler(LogLevel::info());
    $logger->pushHandler($handler);
    
    // Now your logs will be sent to Sentry
    $logger->info('User logged in', ['user_id' => 123]);
    $logger->error('Payment failed', ['order_id' => 456]);

    Note: The handler will not collect logs for exceptions (they should be handled separately via captureException).

Bug Fixes

  • Fix non string indexed attributes passed as log attributes (#1882)
  • Use correct sample_rate key when deriving sampleRand (#1874)
  • Do not call Reflection*::setAccessible() in PHP >= 8.1 (#1872)

Don't miss a new sentry-php release

NewReleases is sending notifications on new releases.