abdogoda/laravel-log-viewer-dashboard

Beautiful, dynamic Laravel log viewer with search, filter, sort, real-time, and stats

Maintainers

Package info

github.com/Abdogoda/laravel-log-viewer-dashboard

pkg:composer/abdogoda/laravel-log-viewer-dashboard

Statistics

Installs: 0

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

dev-master 2026-05-18 00:09 UTC

This package is auto-updated.

Last update: 2026-05-18 00:19:25 UTC


README

Beautiful, dynamic Laravel log viewer with search, filter, sort, real-time updates, and comprehensive statistics.

Features

  • 🔍 Search & Filter - Quickly find logs by message, level, or date
  • 📊 Sort & Paginate - Organize logs with flexible sorting and pagination
  • ⏱️ Real-time Updates - Watch logs as they're created with polling or SSE
  • 🗑️ Flexible Deletion - Delete logs by date, level, pattern, or bulk delete
  • 📈 Statistics - View detailed log statistics and analytics
  • 💻 CLI Commands - Manage logs from terminal
  • 🎨 Beautiful UI - Modern, responsive dashboard built with Tailwind CSS
  • 🔐 Secure - Configurable middleware protection
  • 📱 Responsive - Works on desktop, tablet, and mobile devices

Installation

1. Install via Composer

composer require abdogoda/laravel-log-viewer

2. Publish Configuration (Optional)

php artisan vendor:publish --tag=log-viewer-config

This creates config/log-viewer.php where you can customize:

  • Enabled/Disabled status
  • Route path
  • Middleware
  • Per-page pagination size
  • Timezone
  • Real-time update interval
  • Log levels and colors

Usage

Web Dashboard

Visit /log-viewer in your browser to access the dashboard.

The dashboard features:

  • Live Statistics - Total logs, errors, warnings, and info counts
  • Advanced Filters - Search, level, channel, date range filters
  • Real-time Mode - Toggle real-time log updates
  • Bulk Operations - Delete all logs or refresh data
  • Sort & Paginate - Sort by timestamp, level, channel, or message

CLI Commands

Clear Old Logs

php artisan log-viewer:clear-old --days=30

Deletes all logs older than 30 days (configurable).

Clear All Logs

php artisan log-viewer:clear-all --force

Deletes all log files (with confirmation unless --force is used).

Log Statistics

php artisan log-viewer:stats

Displays statistics about log files including total size and file count.

API Endpoints

Get Logs

GET /log-viewer/api/logs

Query Parameters:

  • file - Log file name
  • search - Search query
  • level - Log level filter
  • channel - Channel filter
  • start_date - Start date filter
  • end_date - End date filter
  • sort_by - Sort field (timestamp, level, channel, message)
  • sort_order - Sort order (asc, desc)
  • per_page - Items per page
  • page - Page number

Get Files

GET /log-viewer/api/files

Returns list of available log files with sizes.

Get Statistics

GET /log-viewer/api/statistics?file=laravel.log

Returns basic statistics or detailed analytics with ?detailed=true.

Delete Operations

Delete All Files

POST /log-viewer/api/delete-all

Delete Specific File

POST /log-viewer/api/delete-file
Body: { "file": "laravel.log" }

Delete Older Than X Days

POST /log-viewer/api/delete-older-than
Body: { "days": 30, "file": "laravel.log" }

Delete by Level

POST /log-viewer/api/delete-by-level
Body: { "levels": ["error", "critical"], "file": "laravel.log" }

Delete by Pattern

POST /log-viewer/api/delete-by-pattern
Body: { "pattern": "Exception", "file": "laravel.log" }

Real-time Endpoints

Stream Logs (SSE)

GET /log-viewer/api/stream?file=laravel.log

Server-Sent Events endpoint for real-time log streaming.

Get Latest Logs

GET /log-viewer/api/latest?file=laravel.log&since=1%20minute%20ago

Configuration

Edit config/log-viewer.php to customize:

return [
    'enabled' => true,                    // Enable/disable the package
    'path' => 'log-viewer',              // Route path
    'middleware' => '',                  // Middleware (e.g., 'auth')
    'per_page' => 50,                    // Logs per page
    'timezone' => 'UTC',                 // Timezone
    'delete_confirmation' => true,       // Show delete confirmation
    'real_time_enabled' => true,         // Enable real-time updates
    'real_time_interval' => 5000,        // Update interval (milliseconds)
    'log_levels' => [                    // Available log levels
        'emergency', 'alert', 'critical', 'error',
        'warning', 'notice', 'info', 'debug'
    ],
    'colors' => [                        // Level colors (hex)
        'emergency' => '#FF0000',
        'alert' => '#FF6600',
        // ... more colors
    ],
];

Security

Protect with Middleware

Add authentication middleware in config/log-viewer.php:

'middleware' => 'auth',  // Only authenticated users

Or use custom middleware:

'middleware' => 'App\Http\Middleware\IsAdmin',

Environment-based Enabling

'enabled' => env('LOG_VIEWER_ENABLED', env('APP_DEBUG', false)),

Architecture

Services

  • LogReader - Reads and parses log files
  • LogFilter - Filters, searches, and sorts logs
  • LogStatistics - Generates statistics and analytics
  • LogDeletion - Handles log file deletion operations

Controllers

  • LogViewerController - Main dashboard and API endpoints
  • RealTimeLogController - Real-time log streaming

Commands

  • ClearOldLogs - Delete logs older than X days
  • ClearAllLogs - Delete all log files
  • LogStats - Display log statistics

Performance Tips

  1. Pagination - The dashboard loads 50 logs per page by default. Adjust via config.
  2. File Size - For very large log files (>100MB), consider cleaning them periodically.
  3. Real-time - Real-time updates poll every 5 seconds by default. Adjust via config.
  4. Deletion - Use log-viewer:clear-old command to automatically clean old logs.

Testing

The package includes basic functionality for testing:

use Abdogoda\LaravelLogViewer\Services\LogReader;

$reader = new LogReader();
$logs = $reader->readLogs();
$stats = $reader->getStatistics();

Troubleshooting

Logs not showing?

  1. Ensure log files exist in storage/logs/
  2. Check file permissions
  3. Verify config path is correct

Real-time not updating?

  1. Check browser console for errors
  2. Ensure real-time is enabled in config
  3. Try manual refresh

Routes not working?

  1. Clear route cache: php artisan route:cache
  2. Check middleware configuration
  3. Verify route prefix in config

License

MIT License - feel free to use in your projects!

Contributing

Contributions are welcome! Please feel free to submit pull requests or issues.

Support

For issues, questions, or suggestions, please visit the GitHub repository.