PHP code example of adminintelligence / laravel-log-shipper

1. Go to this page and download the library: Download adminintelligence/laravel-log-shipper 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/ */

    

adminintelligence / laravel-log-shipper example snippets


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

    'log_shipper' => [
        'driver' => 'custom',
        'via' => \AdminIntelligence\LogShipper\Logging\CreateCustomLogger::class,
        'level' => 'error', // Only ship errors and above
    ],
    
    // ... other channels
],

Log::error('Something went wrong', ['order_id' => 123]);

'send_context' => [
    'user_id' => true,
    'ip_address' => true,
    'user_agent' => false, // disabled
    // ...
],

'status' => [
    'metrics' => [
        'system' => true,
        'queue' => true,
        'database' => true,
        'cache' => false,
        'filesize' => true,
        'foldersize' => true,
        
        // Optional expensive metrics (disabled by default)
        'node_npm' => false,              // Node.js and npm versions
        'dependency_checks' => false,     // Outdated package counts
        'security_audits' => false,       // Security vulnerability counts
    ],

    'monitored_files' => [
        storage_path('logs/laravel.log'),
        storage_path('logs/worker.log'),
    ],
    
    'monitored_folders' => [
        storage_path('logs'),
        storage_path('app/cache'),
    ],
],

'sanitize_fields' => [
    'password',
    'credit_card',
    'ssn', // add your own
    // ...
],

// config/log-shipper.php
'ip_obfuscation' => [
    'enabled' => env('LOG_SHIPPER_IP_OBFUSCATION_ENABLED', false),
    'method' => env('LOG_SHIPPER_IP_OBFUSCATION_METHOD', 'mask'), // 'mask' or 'hash'
],

// config/log-shipper.php
'max_payload_size' => env('LOG_SHIPPER_MAX_PAYLOAD_SIZE', 1048576), // 1MB default

// config/log-shipper.php
'retries' => 3,
'backoff' => [2, 5, 10], // Wait 2s, then 5s, then 10s

// config/log-shipper.php
'circuit_breaker' => [
    'enabled' => true,
    'failure_threshold' => 5, // Open circuit after 5 consecutive failures
    'duration' => 300, // Keep circuit open for 5 minutes
],
bash
php artisan vendor:publish --tag=log-shipper-config

LOG_SHIPPER_ENABLED=true
LOG_SHIPPER_ENDPOINT=https://your-log-server.com/api/ingest
LOG_SHIPPER_KEY=your-project-api-key
LOG_SHIPPER_QUEUE=redis
LOG_SHIPPER_QUEUE_NAME=logs
bash
php artisan vendor:publish --tag=log-shipper-config --force