creative-syntax/laravel-logviewer
Web UI to view, filter, download, and delete Laravel log files. Includes per-level extraction, bulk/selected ZIP downloads, clear/delete actions, configurable route prefix/name and page heading, plus optional access restriction via config/.env authentication.
Installation Run:
composer require creative-syntax/laravel-logviewer
Publish the config (optional):
php artisan vendor:publish --provider="CreativeSyntax\LogViewer\LogViewerServiceProvider"
Basic Usage
/logs route (default).First Use Case
/logs and filtering by error level (e.g., error, critical).auth, database) to isolate relevant entries.Log Filtering
/logs?level=error&search=auth
debug, info, notice, warning, error, critical, alert, emergency.Customizing Log Display
php artisan vendor:publish --tag=logviewer.views
resources/views/vendor/logviewer/logs.blade.php to add columns (e.g., context, extra).Integration with Existing Log Channels
config/logging.php includes the channels you want to monitor (e.g., single, daily, slack).Programmatic Access
LogViewer facade to fetch logs programmatically:
use CreativeSyntax\LogViewer\Facades\LogViewer;
$logs = LogViewer::getLogs(['level' => 'error']);
Middleware for Restricted Access
/logs route by adding middleware (e.g., auth or role:admin) in routes/web.php:
Route::middleware(['auth'])->group(function () {
Route::get('/logs', [LogViewerController::class, 'index']);
});
Log File Permissions
storage/logs/) is writable by the web server user.chmod -R 775 storage/logs/
Large Log Files
Log::channel('single')->info('Custom log entry') with a maxFiles config.tail to stream logs in real-time (not natively supported; may require customization).Custom Log Channels
monolog), ensure they are configured in config/logging.php and the package’s config/logviewer.php includes them:
'channels' => ['single', 'daily', 'monolog'],
Timezone Mismatches
config/logviewer.php:
'timezone' => 'America/New_York',
config/logviewer.php for unexpected behavior (e.g., disabled channels).php artisan config:clear
php artisan view:clear
LogViewer::getLogs() to debug programmatically before UI changes.Custom Log Formatting
LogEntry model (if available) or override the view to format logs (e.g., JSON pretty-printing).Add Log Actions
// app/Http/Controllers/LogViewerController.php
public function clearLogs()
{
$files = Storage::files(storage_path('logs'));
foreach ($files as $file) {
Storage::delete($file);
}
return back()->with('success', 'Logs cleared!');
}
Real-Time Updates
Export Functionality
Route::get('/logs/export', function () {
return response()->json(LogViewer::getLogs())->header('Content-Type', 'application/json');
});
How can I help you explore Laravel packages today?