the-caretakers/laravel-request-logger
Kernel.php).log_profile and log_writer classes allow for granular control over logging logic (e.g., filtering by route, user role, or request type).app/Http/Kernel.php).Log facade and filesystem APIs, minimizing dependency conflicts.web group) to capture all requests or late (e.g., auth group) for authenticated users only.log_profile to filter logs (e.g., only POST requests or error paths).rotate-logs command or integrate with Laravel’s filesystem rotation.Log::channel() with structured logging)?composer require the-caretakers/laravel-request-logger
php artisan vendor:publish --provider="TheCaretakers\RequestLogger\Providers\RequestLoggerServiceProvider" --tag="request-logger-config"
disk to a dedicated filesystem (e.g., logs disk in config/filesystems.php).log_profile to filter requests (e.g., only POST /api/*).config/request-logger.php:
'log_profile' => \App\Services\LogProfile::class, // Custom filter logic
'sanitize' => [
'headers' => ['authorization', 'cookie'],
'payload' => ['password', 'credit_card'],
],
app/Http/Kernel.php:
protected $middleware = [
// ...
\TheCaretakers\RequestLogger\Middleware\RequestLogger::class,
];
Optional: Place in a specific group (e.g., web or api) for targeted logging.storage/app/request-logs/ (or configured disk).php artisan request-logger:rotate.TheCaretakers\RequestLogger\Contracts\LogWriter./health)./api/payments).log_profile or log_writer if needed.config/request-logger.php) reduces drift risk.rotate-logs command or cron job:
* * * * * php artisan request-logger:rotate
filesystem rotation or S3 lifecycle rules).log_profile to log only a subset (e.g., error paths).logs-us, logs-eu).| Failure | Impact | Mitigation |
|---|---|---|
| Disk full | Log writes fail, silent errors | Set up alerts (e.g., Laravel Horizon). |
| Corrupted log files | Incomplete/garbled logs | Use JSON format for structured logs. |
| Middleware exception | Requests fail to log | Wrap middleware in try-catch. |
| Sensitive data leak | PII exposed in logs | Audit sanitize config; test edge cases. |
| High log volume | Performance degradation | Implement sampling or async writes. |
log_profile and test sanitization.log_profile or log_writer.How can I help you explore Laravel packages today?