Centralized Logging

Centralized logging is off by default. When enabled, the package registers a ranetrace Monolog driver you can wire into config/logging.php.

Enable the feature

RANETRACE_LOGGING_ENABLED=true

Add the channel

In config/logging.php:

'channels' => [
    'ranetrace' => [
        'driver' => 'ranetrace',
        'level' => env('LOG_LEVEL', 'notice'),
    ],

    // …
],

The driver is registered as ranetrace via Log::extend('ranetrace', …) in the service provider. The level key is a standard Monolog level — only records at or above that level are forwarded.

Use it in a stack

To send logs to Ranetrace alongside your existing channels, add ranetrace to a stack:

'channels' => [
    'production' => [
        'driver' => 'stack',
        'channels' => ['daily', 'ranetrace'],
        'ignore_exceptions' => false,
    ],

    'ranetrace' => [
        'driver' => 'ranetrace',
        'level' => env('LOG_LEVEL', 'notice'),
    ],
],

Then point the application at the stack:

LOG_CHANNEL=production

You can also log to Ranetrace directly:

use Illuminate\Support\Facades\Log;

Log::channel('ranetrace')->error('Webhook payload missing signature', [
    'provider' => 'stripe',
]);

Excluding channels

The handler skips records whose Monolog channel name appears in ranetrace.logging.excluded_channels. The list is empty by default:

// config/ranetrace.php
'logging' => [
    'excluded_channels' => [
        // Channel names that should never be sent to Ranetrace
    ],
],

Limits applied by the handler

From RanetraceLogHandler:

  • Messages over 50 000 characters are truncated with a ... (truncated) suffix.
  • Context that serializes to more than 50 KB of JSON is replaced with {"_truncated":"Context exceeded 50KB limit and was removed"}.

These keep individual log records well under the API's 5 MB request limit.

Testing your setup

php artisan ranetrace:test-logging

The command checks that the feature is enabled, the channel is defined, sends test entries at multiple levels, and prints what's missing if anything.

Disabling

RANETRACE_LOGGING_ENABLED=false

Records will short-circuit at the handler.