kz370/scollio-logger

Laravel 11 HTTP traffic & exception logger with AJAX dashboard and log rotation.

Installs: 10

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 0

Forks: 0

Open Issues: 0

pkg:composer/kz370/scollio-logger

v1.0.0 2025-10-04 17:00 UTC

This package is auto-updated.

Last update: 2025-11-07 20:54:05 UTC


README

Scollio Logger is a Laravel 11-compatible HTTP traffic and exception logger that automatically records incoming requests, responses, and exceptions โ€” complete with a beautiful AJAX-powered dashboard, configurable middleware control, and automatic log rotation.

Package: kz370/scollio-logger

๐Ÿ“š Table of Contents

๐Ÿš€ Features

  • ๐Ÿง  Automatic request, response, and exception logging
  • ๐Ÿ’พ Database-backed log storage (scollio_logger table)
  • ๐Ÿ–ฅ๏ธ AJAX-powered dashboard with filters and pagination
  • ๐Ÿ” Middleware alias + optional global registration
  • โš™๏ธ Configurable exclusions, key filtering, and rotation
  • ๐Ÿ“… Log retention and automatic cleanup via command
  • ๐Ÿงฉ Modular configuration compatible with Laravel 11

๐Ÿงฉ Requirements

Requirement Minimum Version
PHP 8.2
Laravel 11.x
Database MySQL / PostgreSQL / SQLite / SQL Server

๐Ÿ“ฆ Installation

composer require kz370/scollio-logger

Then publish assets and run migrations:

php artisan vendor:publish --tag=scollio-logger-config
php artisan vendor:publish --tag=scollio-logger-migrations
php artisan vendor:publish --tag=scollio-logger-views
php artisan migrate

Once installed, Scollio Logger automatically registers its routes, views, and middleware.

๐Ÿ›  Publishing Assets

Asset Type Command
Config php artisan vendor:publish --tag=scollio-logger-config
Migrations php artisan vendor:publish --tag=scollio-logger-migrations
Views php artisan vendor:publish --tag=scollio-logger-views

โš™๏ธ Configuration

All configuration values are found in config/scollio-logger.php and can be overridden using .env variables.

Example Core Config

return [
    'enabled' => env('SCOLLIO_ENABLED', true),

    'dashboard' => [
        'enabled' => env('SCOLLIO_LOGGER_DASHBOARD_ENABLED', true),
        'route' => env('SCOLLIO_LOGGER_DASHBOARD_ROUTE', 'scollio-logs/dashboard'),
        'prefix' => 'scollio-logs',
        'middleware' => ['auth:sanctum', 'web'],
        'pagination' => env('SCOLLIO_LOGGER_DASHBOARD_PAGINATION', 25),
    ],

    'middleware' => [
        'global' => env('SCOLLIO_LOGGER_MIDDLEWARE_GLOBAL', true),
    ],

    'paginate' => env('SCOLLIO_PAGINATE', 15),
    'log_web_routes' => env('SCOLLIO_LOG_WEB_ROUTES', true),
    'log_api_routes' => env('SCOLLIO_LOG_API_ROUTES', true),

    'ignore_status_codes' => array_filter(array_map('intval', explode(',', env('SCOLLIO_IGNORE_STATUS_CODES', '302,304,419,429')))),
    'only_status_codes' => array_filter(array_map('intval', explode(',', env('SCOLLIO_ONLY_STATUS_CODES', '')))),

    'retention_days' => env('SCOLLIO_RETENTION_DAYS', 30),
    'rotation_every_minutes' => env('SCOLLIO_ROTATION_EVERY_MINUTES', 1440),
];

โš™๏ธ Environment Variables Reference

Category Environment Key Description Default Type
Core SCOLLIO_ENABLED Enable or disable Scollio Logger globally true boolean
SCOLLIO_PAGINATE Default pagination limit 15 integer
Dashboard SCOLLIO_LOGGER_DASHBOARD_ENABLED Enable or disable the dashboard route true boolean
SCOLLIO_LOGGER_DASHBOARD_ROUTE Dashboard route URI scollio-logs/dashboard string
SCOLLIO_LOGGER_DASHBOARD_PAGINATION Number of logs displayed per page 25 integer
SCOLLIO_LOGGER_MIDDLEWARE_GLOBAL Register logger middleware globally true boolean
Request Logging SCOLLIO_LOG_WEB_ROUTES Log web routes true boolean
SCOLLIO_LOG_API_ROUTES Log API routes true boolean
SCOLLIO_IGNORE_STATUS_CODES Skip these status codes 302,304,419,429 string
SCOLLIO_ONLY_STATUS_CODES Only log specific status codes (empty) string
Rotation SCOLLIO_RETENTION_DAYS Number of days to keep logs 30 integer
SCOLLIO_ROTATION_EVERY_MINUTES Minimum interval between rotations 1440 integer

โœ… Example .env

SCOLLIO_ENABLED=true
SCOLLIO_PAGINATE=15

# Dashboard
SCOLLIO_LOGGER_DASHBOARD_ENABLED=true
SCOLLIO_LOGGER_DASHBOARD_ROUTE=scollio-logs/dashboard
SCOLLIO_LOGGER_DASHBOARD_PAGINATION=25
SCOLLIO_LOGGER_MIDDLEWARE_GLOBAL=true

# Route Logging
SCOLLIO_LOG_WEB_ROUTES=true
SCOLLIO_LOG_API_ROUTES=true
SCOLLIO_IGNORE_STATUS_CODES=302,304,419,429
SCOLLIO_ONLY_STATUS_CODES=

# Rotation & Retention
SCOLLIO_RETENTION_DAYS=30
SCOLLIO_ROTATION_EVERY_MINUTES=1440

๐Ÿงฑ Middleware

Scollio Logger provides both a route middleware alias and an optional global middleware registration.

Mode Description How to Enable
Alias Add scollio-logger to specific routes Always available
Global Automatically logs every request Controlled by config (SCOLLIO_LOGGER_MIDDLEWARE_GLOBAL)

Example Usage:

Route::middleware(['web', 'scollio-logger'])->group(function () {
    Route::get('/dashboard', [DashboardController::class, 'index']);
});

๐Ÿ›ฐ๏ธ Request Logging

When enabled, Scollio captures each request and response with metadata such as method, URL, status code, controller, and duration.

Example Log Entry:

{
  "method": "GET",
  "url": "https://example.com/api/users/5",
  "status_code": 200,
  "duration_ms": 152,
  "controller_action": "App\\Http\\Controllers\\UserController@show"
}

๐Ÿšฆ Dashboard

Visit your dashboard at:

/scollio-logs/dashboard

Dashboard Features

  • Live AJAX search and filtering
  • Filter by method, status, or message
  • View full request and response payloads
  • View exception details and traces
  • Delete individual or all logs
  • Auto-refresh every few seconds
  • Protected by configurable middleware

๐Ÿงน Log Rotation

Scollio includes an Artisan command for automatic cleanup:

php artisan scollio:rotate

This deletes logs older than the configured retention period.

SCOLLIO_RETENTION_DAYS=30
SCOLLIO_ROTATION_EVERY_MINUTES=1440

๐Ÿ“„ Table Schema

Table name: scollio_logger

Column Description
method, url, status_code Request metadata
headers, body, response_headers, response_body Serialized request/response data
exception_message, exception_trace Exception info
requested_at, responded_at, duration_ms Timing metrics
route_action, user_id, session_id, request_id Contextual info

๐Ÿ–ผ๏ธ Screenshots

Scollio Logger Dashboard Single Log Entry View

๐Ÿงฉ Troubleshooting

Issue Possible Cause Recommended Solution
No logs showing Logging disabled, migrations not run, or middleware missing 1. Ensure .env has SCOLLIO_ENABLED=true. 2. Run php artisan migrate. 3. If using alias, ensure routes include scollio-logger.
Dashboard 404 Routes not cached or dashboard disabled 1. Run php artisan route:clear. 2. Ensure SCOLLIO_LOGGER_DASHBOARD_ENABLED=true. 3. Visit /scollio-logs/dashboard.
Old data not deleting Rotation not scheduled 1. Confirm SCOLLIO_RETENTION_DAYS and SCOLLIO_ROTATION_EVERY_MINUTES. 2. Add scheduler entry: $schedule->command('scollio:rotate')->daily();
Performance issues Too much payload or high retention 1. Lower retention days. 2. Exclude unnecessary routes using skip_routes.

๐Ÿ“œ License

Released under the MIT License.

๐Ÿงฉ Scollio Logger โ€” Smart, structured, and searchable HTTP and exception logging for Laravel.