Enhancing Laravel Application Logging with Customization and Persistence

Option 1: Laravel Log Viewer Package

Install via Composer:

composer require rap2hpoutre/laravel-log-viewer

Register the service porvider in config/app.php:

Rap2hpoutre\LaravelLogViewer\LaravelLogViewerServiceProvider::class,

Define route access:

Route::get('logs', [\Rap2hpoutre\LaravelLogViewer\LogViewerController::class, 'index']);

Secure access implementation:

<?php

namespace App\Http\Controllers\Admin;

use Illuminate\Http\Request;
use Illuminate\Support\Facades\URL;
use Rap2hpoutre\LaravelLogViewer\LogViewerController;
use Exception;

class LogAccessController extends BaseController
{
    public function authenticate(Request $request)
    {
        try {
            $username = $request->input('username');
            $password = $request->input('password');
            
            if ($username === config('log.auth.username') && 
                $password === config('log.auth.password')) {
                
                session(['log_access_token' => true]);
                return redirect(URL::to('/log-dashboard'));
            }
            
            abort(403, 'Invalid credentials');
            
        } catch (Exception $e) {
            abort(403, 'Authentication failed');
        }
    }

    public function showDashboard(Request $request)
    {
        if (!session('log_access_token')) {
            abort(403, 'Please authenticate first');
        }
        
        $viewer = new LogViewerController($request);
        return $viewer->index($request);
    }
}

Features: Supports hierarchical directory scanning, search functionality, and optimized performance

Option 2: Arcanedev Log Viewer

Installation commmand:

composer require arcanedev/log-viewer

Configuration setup:

'providers' => [
    Arcanedev\LogViewer\LogViewerServiceProvider::class,
],

Route configuration with middleware:

'route' => [
    'enabled' => true,
    'attributes' => [
        'prefix' => 'log-panel',
        'middleware' => ['web', 'log.authorization'],
    ],
],

Authorization middleware implementation:

public function handle($request, Closure $next)
{
    if (!session('log_viewer_token')) {
        abort(403, 'Access denied - please authenticate');
    }
    
    return $next($request);
}

Features: JSON formatting support, visual statistics, and template-based rendering (slower initial load)

Option 3: Enterprise Logging Infrastructure

Production-grade solutions:

  • EFK Stack: Elasticsearch, Fluentd, Kibana - requires significant server resources
  • Prometheus + Grafana: Excellent for Kubernetes environments with customizable dashboards

Option 4: Industry-Specific Logging Systems

  • Melon Logger: Recommended for user behavior analysis with SDK support for multiple platforms
  • XLog: Tenecnt's solution requiring custom SDK development

Tags: laravel log-viewer middleware elasticsearch prometheus

Posted on Fri, 18 Sep 2026 16:10:02 +0000 by zuperxtreme