foxen/laravel-validation-error-logger
Log Laravel validation errors automatically from FormRequest classes using a simple trait. Configure the log channel and exclude sensitive fields (e.g., passwords) via a published config file, with per-request overrides available.
ValidationErrorLogger) and integrates seamlessly with Laravel’s existing validation pipeline (via FormRequest or manual validation). It does not introduce new database tables, queues, or complex dependencies, making it ideal for applications where validation error logging is a secondary concern rather than a core feature.Validating event) and logging stack (log() helper), reducing friction for adoption.FormRequest classes or routes).single or stack with synchronous drivers). Mitigation: Use async channels (e.g., syslog, monolog with queue handler) or filter errors via config.exclude_fields and validation of the package’s sanitization logic.FormRequest integration, excluded fields).stack vs. database).exclude_fields that contain PII? Audit all validators and request payloads.database/filesystem)?log:monitor.\Log::error()) or packages like spatie/laravel-logging for feature parity (e.g., structured logging, retention).FormRequest, Validator, or manual validation. Works with Laravel 8+ (assumed based on release date).config/logging.php (e.g., single, stack, monolog, syslog). Recommendation: Use stack with async drivers (e.g., monolog + queue) to avoid blocking.Validating event or via trait in FormRequest classes. Best Practice: Use the trait sparingly (e.g., only for high-value endpoints).FormRequest class to validate output format and performance.FormRequest classes via a base class (e.g., App\Http\Requests\BaseRequest).Validating event listener to log globally (more invasive; requires event binding).exclude_fields in config (e.g., ['password', 'api_token', 'cc_number']).log_channel to an async-compatible channel (e.g., monolog with async queue handler).composer.json constraints or test locally.Validator::extend()). Workaround: Extend the trait or use Validator::after().Validator::make()->validate()) won’t auto-log. Solution: Wrap in a helper or use the trait’s static method if available.php artisan log:read) to understand baseline noise.filesystem, archival for database)./api/register).storage/logs/laravel.log).tideways or blackfire.io profiling).validation.failed events).exclude_fields and log_channel are well-defined. Risk: Config drift if multiple teams modify validation-error-logger.php.composer.json if using pre-release.filesystem driver) aligns with retention needs.error vs. debug).laravel-monolog-queue-channel) or access controls.stack with single driver). Mitigation: Use async channels (e.g., monolog with async queue handler).database channel, ensure the failed_jobs table (or custom table) can handle write load. Recommendation: Use a dedicated logging table with indexing on level and created_at.| Failure Scenario | Impact | Mitigation |
|---|---|---|
| Log channel misconfiguration | Errors silently dropped | Validate log_channel in config and test. |
| PII in logs | Compliance/privacy breach | Audit exclude_fields and use log masking. |
| High log volume | Disk I/O bottlenecks, cost (cloud) | Implement log rotation/sampling. |
| Package abandonment | Unpatched vulnerabilities | Fork or pin version; monitor GitHub activity. |
| Validation error storms | Log channel overload | Rate-limit logging (e.g., per endpoint/IP). |
use Foxen\LaravelValidationErrorLogger\Traits\ValidationErrorLogger; in FormRequest").exclude_fields config as a security requirement.validation.failed in ELK).How can I help you explore Laravel packages today?