justbetter/nova-error-logger
Laravel Nova integration for justbetter/laravel-error-logger. Install via Composer and view logged application errors inside Nova. Versioning matches Nova major versions (v4 for Nova 4, v3 for Nova 3; older versions for earlier Nova releases).
Installation:
composer require justbetter/nova-error-logger
Publish the config file (if needed):
php artisan vendor:publish --provider="JustBetter\NovaErrorLogger\NovaErrorLoggerServiceProvider"
First Use Case:
justbetter/laravel-error-logger is installed in your Laravel app (this package is an extension for Nova).NovaServiceProvider:
use JustBetter\NovaErrorLogger\ErrorLogger;
public function tools()
{
return [
new ErrorLogger,
];
}
Error Logging Integration:
justbetter/laravel-error-logger (e.g., Log::error() or throw new \JustBetter\ErrorLogger\ErrorLoggerException) will auto-populate the Nova dashboard.ErrorLogger facade in your app:
use JustBetter\ErrorLogger\Facades\ErrorLogger;
ErrorLogger::log(new \Exception("Test error"));
Nova Dashboard Usage:
Customizing Log Display:
app/Nova/ErrorLogger.php:
public function fields(Request $request)
{
return [
ID::make()->sortable(),
Text::make('Message')->sortable(),
Text::make('Stack Trace')->onlyOnDetail(),
// Add custom fields from your error context
Text::make('Custom Field', function ($error) {
return $error->context['custom_key'] ?? null;
}),
];
}
Automated Alerts:
public function actions(Request $request)
{
return [
(new AlertAction)->setButtonLabel('Notify Team'),
];
}
Dependency Mismatch:
justbetter/laravel-error-logger is installed in your Laravel app. Nova’s tool is not a standalone logger.^4.0 for Nova 4.x).Permission Issues:
view error-logger permission. Assign via Nova’s Permissions tool:
Nova::permissions([
'view error-logger' => 'View error logs',
]);
Performance:
perPage() method to limit results:
public function indexQuery(Nova $nova, Request $request)
{
return parent::indexQuery($nova, $request)->paginate(50);
}
Context Data:
ErrorLogger::log(new Exception())) will lack metadata. Attach context explicitly:
ErrorLogger::log(new Exception("Payment failed"), [
'user_id' => auth()->id(),
'amount' => $request->amount,
]);
Logs Not Appearing?
Verify justbetter/laravel-error-logger is configured in config/error-logger.php and errors are being logged to the correct channel (e.g., error_logger).
Check Laravel logs (storage/logs/laravel.log) for initialization errors.
Stack Trace Formatting:
If stack traces are truncated, override the StackTrace field in the Nova resource:
Textarea::make('Stack Trace')->onlyOnDetail()->asHtml(),
Custom Error Types:
Extend the base Error model to add fields:
// app/Models/Error.php
class Error extends \JustBetter\ErrorLogger\Models\Error
{
protected $casts = [
'metadata' => 'array',
];
}
Nova Tool Branding:
Customize the tool’s appearance in resources/js/tools/ErrorLogger/Tool.jsx (if you’ve published assets):
<TitleBar title="Custom Error Tracker" />
Webhook Integration: Use Nova’s Actions to POST error data to an external API:
public function handle(Nova $nova, $error)
{
Http::post('https://your-api.com/webhooks', [
'error' => $error->toArray(),
]);
}
How can I help you explore Laravel packages today?