composer require srmilon/log-viewer
Srmilon\LogViewer\LogServiceProvider::class to config/app.php under providers.php artisan vendor:publish --provider="Srmilon\LogViewer\LogServiceProvider" --tag=views
routes/web.php, add:
Route::get('/log', '\Srmilon\LogViewer\LogViewerController@index');
/log in your browser to view Laravel logs in detail.Development Workflow:
/log as a live dashboard to monitor application behavior.error, info), or keyword.SQLSTATE[HY000] to debug database issues.Production Workflow:
auth or role checks).storage/logs/errors.log) and exclude them from the viewer for security.Integration with Monitoring:
resources/views/vendor/log-viewer templates to match your app’s design.LogViewerController or creating a middleware to pre-process logs.Route::get('/log', function () {
if (!auth()->check() || !auth()->user()->isAdmin()) {
abort(403);
}
return app(\Srmilon\LogViewer\LogViewerController::class)->index();
});
storage/logs/ is readable only by the web server user (e.g., chmod 640 storage/logs/*).Outdated Code:
composer require nikic/php-parser if syntax errors arise due to PHP version mismatches.Performance Impact:
// In LogViewerController, override the query to fetch recent logs only
$logs = Log::query()->latest()->take(1000)->get();
Log File Rotation:
laravel-log-rotate), the viewer may not show recent logs. Ensure the package reads the correct log file (default: storage/logs/laravel.log).Missing Dependencies:
Logs Not Showing?:
config/logging.php matches the package’s expectations.ls -la storage/logs/.config/app.php to see errors: 'debug' => env('APP_DEBUG', true).Blank Page:
php artisan view:clear.storage/logs/laravel.log.Filtering:
// In the published view, add:
<input type="text" id="log-search" onkeyup="filterLogs()">
Log Level Highlighting:
error, green for info):
.log-error { color: red; }
.log-info { color: green; }
Export Logs:
Route::get('/log/export', function () {
return response()->json(Log::all()->toArray());
});
Environment-Specific Routes:
if (app()->environment('local')) {
Route::get('/log', '\Srmilon\LogViewer\LogViewerController@index');
}
Alternative for Modern Laravel:
spatie/laravel-log-viewer (more maintained).beberlei/laravel-log-viewer (supports Monolog).How can I help you explore Laravel packages today?