tfspl/restlogger
A Laravel package that logs incoming and outgoing REST API requests and responses, helping you debug integrations, trace errors, and monitor API activity. Configurable logging for headers, payloads, and status codes.
This release (2.1.2) is a maintenance patch — composer metadata, README corrections, and log-handling tweaks — so there are no migration steps from 2.1.1. Treat the README refresh as the authoritative setup guide since the require field was corrected alongside it.
composer require sunny-mahajan/laravel-rest-apis-logger.php artisan vendor:publish --provider="SunnyMahajan\RestApisLogger\RestApisLoggerServiceProvider" (tag/config/migrations may differ — check the published README's provider class name).php artisan migrate to create the API log table.app/Http/Kernel.php (or bootstrap/app.php on Laravel 11+) — typically appended to the api middleware group so it captures every REST route.First use case: drop the middleware on your api group and you immediately get a request/response audit trail (method, path, payload, status, timing) without touching controller code.
Global API logging. Add the middleware to the api group in the HTTP kernel. This is the lowest-effort pattern and covers all versioned API routes at once.
Scoped logging. Register the middleware as a route middleware alias and apply it only to sensitive or high-value routes (e.g. ->middleware('api-logger') on payment or auth endpoints) so you avoid table bloat on noisy health-check or webhook routes.
Custom log model. If you need extra columns or relationships, extend the package's log model and point the config at your subclass. This keeps package upgrades intact while letting you attach user_id, tenant IDs, or correlate to an internal request ID.
Config-driven filtering. Use the published config to toggle logging, set the storage connection, and exclude paths. Prefer excluding via config over conditional middleware placement — it's easier to audit and change per environment.
Pair with auth context. Log after authentication middleware runs so you can enrich entries with the authenticated user. Middleware ordering matters here: the logger should run after auth but still capture the response, which means relying on the terminating phase rather than just the request phase.
Environment gating. Enable full payload logging in staging, and restrict to metadata (status, duration, route) in production if compliance or volume is a concern. The corrected composer.json/require field in 2.1.2 mainly affects install-time dependency resolution, so pin your Laravel version explicitly if you're on an older LTS.
handle(), you'll record the request but miss the actual response payload and status.php artisan model:prune or a scheduled delete) or the table will balloon fast on busy APIs.php artisan config:clear (or config:cache) — stale cached config is the most common "why isn't it logging" cause.auth means unauthenticated requests get logged too (often desirable) but user context is missing; placing it after means auth failures are invisible. Decide deliberately.How can I help you explore Laravel packages today?