PHP code example of leek / laravel-compact-logs

1. Go to this page and download the library: Download leek/laravel-compact-logs 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/ */

    

leek / laravel-compact-logs example snippets


// config/compact-logs.php
return [
    // Channels to apply truncation to (set to null to disable auto-registration)
    'channels' => ['single', 'daily'],

    // Max stack trace frames per exception
    'max_trace_depth' => (int) env('LOG_TRACE_DEPTH', 3),
];

'single' => [
    'driver' => 'single',
    'tap'    => [\Leek\CompactLogs\CompactExceptionTap::class],
    'path'   => storage_path('logs/laravel.log'),
    'level'  => env('LOG_LEVEL', 'debug'),
],

[2026-02-12 08:37:31] local.ERROR: Connection refused {"exception":"[object] (PDOException...)
[stacktrace]
#0 /vendor/laravel/framework/src/.../Connection.php(420): PDO->prepare(...)
#1 /vendor/laravel/framework/src/.../Connection.php(827): ...
#2 /vendor/laravel/framework/src/.../Connection.php(794): ...
#3 /vendor/laravel/framework/src/.../Connection.php(411): ...
... 80 more lines of framework internals ...

[2026-02-12 08:37:31] local.ERROR: Connection refused {"exception":"[object] (PDOException...)
[stacktrace]
#0 /vendor/laravel/framework/src/.../Connection.php(420): PDO->prepare(...)
#1 /vendor/laravel/framework/src/.../Connection.php(827): ...
#2 /vendor/laravel/framework/src/.../Connection.php(794): ...
... and 80 more frames"}
bash
php artisan vendor:publish --tag=compact-logs-config