laravel/nova-log-viewer
View and search your Laravel application logs directly inside Laravel Nova. Nova Log Viewer adds a simple tool UI with real-time polling support, making it easy to inspect errors, stack traces, and recent log entries without leaving the admin panel.
Installation Run the following command in your Laravel project directory:
composer require laravel/nova-log-viewer
Registration
Register the tool in your NovaServiceProvider (app/Providers/NovaServiceProvider.php):
public function tools()
{
return [
\Laravel\Nova\LogViewer\LogViewer::make(),
// ... other tools
];
}
First Use Case
error, debug) or keyword (e.g., authentication).Real-Time Log Monitoring
LogViewer::make()->withPollingInterval(5); // Refresh every 5 seconds
Debugging with Nova
error, warning) or search for keywords.User resource for context):
LogViewer::make()->viaResource(\App\Nova\User::class);
Integration with Nova Features
php artisan vendor:publish --tag=nova-log-viewer
resources/views/vendor/nova.Log Management
Log::clear() (if extended in a custom tool)..env:
LOG_MAX_FILES=5
Conditional Tool Registration
public function tools()
{
if (app()->environment('production')) {
return [
LogViewer::make(),
];
}
return [];
}
Log-Level-Specific Tools
LogViewer::make()->withLogLevel('error')->name('Error Logs'),
LogViewer::make()->withLogLevel('debug')->name('Debug Logs'),
Polling Optimization
LogViewer::make()->withPollingInterval(30); // Every 30 seconds
RBAC for Log Access
Admin):
LogViewer::make()->authorize(function ($request) {
return $request->user()->can('view logs');
});
Polling Performance Issues
1s) can overload the server.10s) and adjust based on log volume.nova.log for polling-related errors.Missing Log Files
LOG_CHANNEL in .env points to a valid driver (e.g., single, daily).storage/logs/.Authentication Bypass
403 instead of a redirect.Authenticate middleware is properly registered (fixed in v1.2.0+).Large Log Files Slowing Nova
Check Nova’s Logs
storage/logs/nova.log.Verify Tool Registration
NovaServiceProvider::tools() and no syntax errors exist.Polling Debugging
LogViewer::make()->withoutPolling();
Log Driver Issues
single log driver for simplicity:
LOG_CHANNEL=single
Custom Log Paths
storage/logs/laravel.log. To change:
LogViewer::make()->withLogPath('custom/path/to/logs');
Environment-Specific Settings
$interval = app()->environment('local') ? 2 : 10;
LogViewer::make()->withPollingInterval($interval);
Tool Visibility
LogViewer::make()->visible(function ($request) {
return $request->user()->isAdmin();
});
Custom Log Parsing
resolveLogContents method in a custom tool class.Add Log Actions
LogViewer::make()->withActions([
new ReplayJobAction,
]);
Log Correlation
app/Providers/AppServiceProvider.php.Export Logs
handleExport method.Reduce Polling Overhead
Log File Rotation
LOG_MAX_FILES=7
LOG_LEVEL=debug
Caching Log Metadata
Log Access Control
LogViewer::make()->authorize(function ($request) {
return $request->user()->hasRole(['admin', 'dev']);
});
Sensitive Data in Logs
Log::withContext().Log File Permissions
chmod -R 755 storage/
How can I help you explore Laravel packages today?